Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The CPython Pixi packages are now all accessible at the same
``Tools/pixi-packages`` subdirectory, rather than at
``Tools/pixi-packages/{variant}`` as before. Variants are now selected not
via subdirectory but via ``flags``; see
https://pixi.prefix.dev/latest/concepts/package_specifications/#extras-and-flags
for usage instructions. The ``tsan-freethreading`` variant has been renamed
to ``tsan_freethreading``, while the ``default``, ``asan``, and
``freethreading`` variants retain their previous names.
14 changes: 7 additions & 7 deletions Tools/pixi-packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ in a [Pixi workspace](https://pixi.sh/latest/first_workspace/), like:
```toml
[dependencies]
python.git = "https://github.com/python/cpython"
python.subdirectory = "Tools/pixi-packages/asan"
python.subdirectory = "Tools/pixi-packages"
python.flags = ["asan"]
```

This is particularly useful when developers need to build CPython from source
(for example, for an ASan or TSan-instrumented build), as it does not require any manual
clone or build steps. Instead, Pixi will automatically handle both the build
and installation of the package.

Each package definition is contained in a subdirectory, but they share the build script
`build.sh` in this directory. Currently defined package variants:
Each package variant carries a 'flag' to enable selection of that variant — see
[the Pixi docs](https://pixi.prefix.dev/latest/concepts/package_specifications/#extras-and-flags)
for details of how to use this. Currently defined package variants:

- `default`
- `freethreading`
- `asan`: ASan-instrumented build
- `tsan-freethreading`: TSan-instrumented free-threading build
- `tsan_freethreading`: TSan-instrumented free-threading build

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to remove the - from this variant name, given that it is invalid in the flags field: https://conda.org/learn/ceps/cep-0045#repodata-record-syntax

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me, I think you and @crusaderky are just about the only users of these builds so far for what its worth


## Maintenance

- Keep the `abi_tag` and `version` fields in each `variants.yaml` up to date with the
- Keep the `version` field in `variants.yaml` up to date with the
Python version
- Update `build.sh` for any breaking changes in the `configure` and `make` workflow

## Opportunities for future improvement

- More package variants (such as UBSan)
- Support for Windows
- Using a single `pixi.toml` for all package variants is blocked on
[pixi#5248](https://github.com/prefix-dev/pixi/issues/5248)

## Troubleshooting

Expand Down
6 changes: 0 additions & 6 deletions Tools/pixi-packages/asan/variants.yaml

This file was deleted.

10 changes: 9 additions & 1 deletion Tools/pixi-packages/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [[ "${PYTHON_VARIANT}" == "freethreading" ]]; then
elif [[ "${PYTHON_VARIANT}" == "asan" ]]; then
CONFIGURE_EXTRA="--with-address-sanitizer"
export ASAN_OPTIONS="strict_init_order=true"
elif [[ "${PYTHON_VARIANT}" == "tsan-freethreading" ]]; then
elif [[ "${PYTHON_VARIANT}" == "tsan_freethreading" ]]; then
CONFIGURE_EXTRA="--disable-gil --with-thread-sanitizer"
export TSAN_OPTIONS="suppressions=${SRC_DIR}/Tools/tsan/suppressions_free_threading.txt"
elif [[ "${PYTHON_VARIANT}" == "default" ]]; then
Expand All @@ -17,6 +17,14 @@ else
exit 1
fi

VER_REF=$(grep "\[PYTHON_VERSION\]\, \[" configure.ac | sed -n 's/.*\[\([0-9.]*\)\].*/\1/p')
VER=$(echo ${PKG_VERSION} | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')

if [[ "${VER_REF}" != "${VER}" ]]; then
echo "Unexpected version from conda package. Got ${VER}. Expected ${VER_REF}. Do you need to update `version` in `variants.yaml`?"
exit 1
fi

# rattler-build by default set a target of 10.9
# override it to at least 10.12
case ${MACOSX_DEPLOYMENT_TARGET:-10.12} in
Expand Down
10 changes: 0 additions & 10 deletions Tools/pixi-packages/clone-recipe.sh

This file was deleted.

15 changes: 0 additions & 15 deletions Tools/pixi-packages/default/pixi.toml

This file was deleted.

6 changes: 0 additions & 6 deletions Tools/pixi-packages/default/variants.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions Tools/pixi-packages/freethreading/pixi.toml

This file was deleted.

6 changes: 0 additions & 6 deletions Tools/pixi-packages/freethreading/variants.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# NOTE: Please always only modify default/pixi.toml and then run clone-recipe.sh to
# propagate the changes to the other variants.

[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64"]
preview = ["pixi-build"]
requires-pixi = ">=0.66.0"
requires-pixi = ">=0.72.2"

[package.build.backend]
name = "pixi-build-rattler-build"
version = "*"

[package.build.config]
recipe = "../default/recipe.yaml"
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# NOTE: Please always only modify default/recipe.yaml and then run clone-recipe.sh to
# propagate the changes to the other variants.

context:
# Keep up to date
freethreading_tag: ${{ "t" if "freethreading" in variant else "" }}
abi_prefix: ${{ (variant | split("_"))[0] + "_" if "san" in variant else "" }}
abi_tag: ${{ abi_prefix }}cp${{ (version | split('.'))[:2] | join('') }}${{ freethreading_tag }}

recipe:
name: python

source:
- path: ../../..
- path: ../..

outputs:
- package:
Expand All @@ -25,12 +23,16 @@ outputs:
name: python
version: ${{ version }}
build:
flags:
- ${{ variant }}
variant:
down_prioritize_variant: ${{ 0 if variant == "default" else 1 }}
string: "0_${{ abi_tag }}"
files:
exclude:
- "*.o"
script:
file: ../build.sh
file: build.sh
env:
PYTHON_VARIANT: ${{ variant }}
python:
Expand Down
15 changes: 0 additions & 15 deletions Tools/pixi-packages/tsan-freethreading/pixi.toml

This file was deleted.

6 changes: 0 additions & 6 deletions Tools/pixi-packages/tsan-freethreading/variants.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions Tools/pixi-packages/variants.yaml
Comment thread
lucascolley marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: ["3.16"]
variant: ["default", "asan", "freethreading", "tsan_freethreading"]

openssl:
- '3.5'

c_compiler:
- clang
c_compiler_version:
- 21
cxx_compiler:
- clangxx
cxx_compiler_version:
- 21
Comment on lines +4 to +14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add comments explaining these pin choices?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kumaraditya303 how would you explain when these need to be updated, and where to look for the new versions?

Loading