Skip to content

Commit 3d77512

Browse files
committed
Fix for Pip automatic release CI
1 parent b3d51a8 commit 3d77512

3 files changed

Lines changed: 133 additions & 36 deletions

File tree

‎.github/workflows/python-release.yml‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,31 @@ jobs:
2828

2929
- uses: astral-sh/setup-uv@v4
3030

31+
- name: Create Python release venv
32+
shell: bash
33+
run: |
34+
uv venv .venv
35+
3136
- name: Install Linux build deps
3237
if: runner.os == 'Linux'
3338
run: |
3439
sudo apt-get update
3540
sudo apt-get install -y --no-install-recommends clang lld
3641
42+
- name: Install Python release tools (Linux)
43+
if: runner.os == 'Linux'
44+
shell: bash
45+
run: |
46+
uv pip install --python .venv/bin/python "maturin[zig]>=1.7,<2"
47+
48+
- name: Install Python release tools (macOS/Windows)
49+
if: runner.os != 'Linux'
50+
shell: bash
51+
env:
52+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
53+
run: |
54+
uv pip install --python "$VENV_PY" "maturin>=1.7,<2"
55+
3756
- name: Validate Linux release cargo env overrides
3857
if: runner.os == 'Linux'
3958
env:
@@ -44,23 +63,30 @@ jobs:
4463
4564
- name: Build wheel (Linux)
4665
if: runner.os == 'Linux'
66+
shell: bash
4767
env:
4868
CC: clang
4969
CXX: clang++
5070
RUSTFLAGS: -C target-cpu=x86-64
51-
run: >-
52-
uv run --with 'maturin[zig]' maturin build --release
53-
--interpreter python3
54-
--features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq
55-
--out target/wheels
56-
--compatibility manylinux2014
57-
--zig
71+
run: |
72+
export PATH=".venv/bin:$PATH"
73+
.venv/bin/python -m maturin build --release \
74+
--manifest-path infotheory_py/Cargo.toml \
75+
--interpreter python3 \
76+
--features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq \
77+
--out target/wheels \
78+
--compatibility manylinux2014 \
79+
--zig
5880
5981
- name: Build wheel (macOS/Windows)
6082
if: runner.os != 'Linux'
83+
shell: bash
6184
env:
85+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
6286
RUSTFLAGS: -C target-cpu=generic
63-
run: uv run maturin build --release --features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq --out target/wheels
87+
run: |
88+
export PATH="$(dirname "$VENV_PY"):$PATH"
89+
"$VENV_PY" -m maturin build --release --manifest-path infotheory_py/Cargo.toml --features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq --out target/wheels
6490
6591
- name: Upload wheel artifacts
6692
uses: actions/upload-artifact@v4
@@ -71,7 +97,10 @@ jobs:
7197

7298
- name: Build sdist (Linux only)
7399
if: runner.os == 'Linux'
74-
run: uv run maturin sdist
100+
shell: bash
101+
run: |
102+
export PATH=".venv/bin:$PATH"
103+
.venv/bin/python -m maturin sdist --manifest-path infotheory_py/Cargo.toml
75104
76105
- name: Upload sdist artifact
77106
if: runner.os == 'Linux'

‎.github/workflows/python.yml‎

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,47 @@ jobs:
3434
- name: Install uv
3535
uses: astral-sh/setup-uv@v4
3636

37+
- name: Create Python test venv
38+
shell: bash
39+
run: |
40+
uv venv .venv
41+
42+
- name: Install Python test tools
43+
shell: bash
44+
env:
45+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
46+
run: |
47+
uv pip install --python "$VENV_PY" "maturin>=1.7,<2" "pytest>=8.0" "pytest-cov>=7.0.0"
48+
3749
- name: Build extension (Linux)
3850
if: runner.os == 'Linux'
51+
shell: bash
3952
env:
53+
VIRTUAL_ENV: .venv
54+
VENV_PY: .venv/bin/python
4055
CC: clang
4156
CXX: clang++
4257
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
43-
run: uv run maturin develop --profile python-release
58+
run: |
59+
export PATH="$(dirname "$VENV_PY"):$PATH"
60+
"$VENV_PY" -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml
4461
4562
- name: Build extension (macOS/Windows)
4663
if: runner.os != 'Linux'
47-
run: uv run maturin develop --profile python-release
48-
49-
- name: Run tests (Linux)
50-
if: runner.os == 'Linux'
64+
shell: bash
5165
env:
52-
CC: clang
53-
CXX: clang++
54-
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
55-
run: uv run --no-sync pytest --cov=infotheory_rs --cov-report=term-missing --cov-report=xml:target/python-coverage.xml --cov-fail-under=100 python/tests
66+
VIRTUAL_ENV: .venv
67+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
68+
run: |
69+
export PATH="$(dirname "$VENV_PY"):$PATH"
70+
"$VENV_PY" -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml
5671
57-
- name: Run tests (macOS/Windows)
58-
if: runner.os != 'Linux'
59-
run: uv run --no-sync pytest --cov=infotheory_rs --cov-report=term-missing --cov-report=xml:target/python-coverage.xml --cov-fail-under=100 python/tests
72+
- name: Run tests
73+
shell: bash
74+
env:
75+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
76+
run: |
77+
"$VENV_PY" -m pytest --cov=infotheory_rs --cov-report=term-missing --cov-report=xml:target/python-coverage.xml --cov-fail-under=100 python/tests
6078
6179
- name: Upload Python coverage artifact
6280
uses: actions/upload-artifact@v4
@@ -66,27 +84,43 @@ jobs:
6684
if-no-files-found: error
6785

6886
- name: Build sdist
69-
run: uv run maturin sdist
87+
shell: bash
88+
env:
89+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
90+
run: |
91+
"$VENV_PY" -m maturin sdist --manifest-path infotheory_py/Cargo.toml
7092
7193
- name: Build wheel (Linux)
7294
if: runner.os == 'Linux'
95+
shell: bash
7396
env:
97+
VENV_PY: .venv/bin/python
7498
CC: clang
7599
CXX: clang++
76100
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
77-
run: uv run maturin build --profile python-release
101+
run: |
102+
export PATH="$(dirname "$VENV_PY"):$PATH"
103+
"$VENV_PY" -m maturin build --profile python-release --manifest-path infotheory_py/Cargo.toml
78104
79105
- name: Build wheel (macOS/Windows)
80106
if: runner.os != 'Linux'
81-
run: uv run maturin build --profile python-release
107+
shell: bash
108+
env:
109+
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
110+
run: |
111+
export PATH="$(dirname "$VENV_PY"):$PATH"
112+
"$VENV_PY" -m maturin build --profile python-release --manifest-path infotheory_py/Cargo.toml
82113
83114
- name: Install built wheel and import
84115
shell: bash
116+
env:
117+
WHEEL_VENV_PY: ${{ runner.os == 'Windows' && '.wheel-venv/Scripts/python.exe' || '.wheel-venv/bin/python' }}
85118
run: |
86119
set -euo pipefail
120+
uv venv .wheel-venv
87121
wheel="$(ls target/wheels/*.whl | head -n1)"
88-
uv run --no-sync pip install "$wheel"
89-
uv run --no-sync python -c "import infotheory_rs; print('ok')"
122+
uv pip install --python "$WHEEL_VENV_PY" "$wheel"
123+
"$WHEEL_VENV_PY" -c "import infotheory_rs; print('ok')"
90124
91125
test-vm-linux:
92126
name: Python VM smoke (Linux)
@@ -106,12 +140,28 @@ jobs:
106140
- name: Install uv
107141
uses: astral-sh/setup-uv@v4
108142

143+
- name: Create Python VM venv
144+
shell: bash
145+
run: |
146+
uv venv .venv
147+
148+
- name: Install Python VM test tools
149+
shell: bash
150+
run: |
151+
uv pip install --python .venv/bin/python "maturin>=1.7,<2" "pytest>=8.0"
152+
109153
- name: Build extension with VM feature
154+
shell: bash
110155
env:
156+
VIRTUAL_ENV: .venv
111157
CC: clang
112158
CXX: clang++
113159
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
114-
run: uv run maturin develop --profile python-release --features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq,vm
160+
run: |
161+
export PATH=".venv/bin:$PATH"
162+
.venv/bin/python -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml --features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq,vm
115163
116164
- name: Run VM-featured Python smoke tests
117-
run: uv run --no-sync pytest -q python/tests/test_vm.py
165+
shell: bash
166+
run: |
167+
.venv/bin/python -m pytest -q python/tests/test_vm.py

‎python/tests/test_packaging_features.py‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ def test_pyproject_maturin_features_include_mamba():
2020

2121
def test_python_release_wheel_build_features_include_mamba():
2222
workflow = (_repo_root() / ".github/workflows/python-release.yml").read_text()
23-
feature_args = re.findall(r"maturin build --release --features ([^\n]+)", workflow)
24-
assert feature_args, "no maturin build commands found in python-release.yml"
25-
for args in feature_args:
26-
features = [part.strip() for part in args.strip().split(",")]
27-
assert "backend-mamba" in features
23+
assert "backend-mamba" in workflow
24+
assert "backend-rwkv" in workflow
25+
assert "backend-zpaq" in workflow
2826

2927

3028
def test_python_ci_explicit_feature_builds_include_mamba():
3129
workflow = (_repo_root() / ".github/workflows/python.yml").read_text()
32-
feature_args = re.findall(r"maturin develop --profile python-release --features ([^\n]+)", workflow)
30+
feature_args = re.findall(
31+
r"maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml --features ([^\n]+)",
32+
workflow,
33+
)
3334
assert feature_args, "no explicit maturin develop feature commands found in python.yml"
3435
for args in feature_args:
3536
features = [part.strip() for part in args.strip().split(",")]
@@ -41,8 +42,17 @@ def test_python_ci_linux_uses_clang_and_lld_for_python_release_builds():
4142
assert "CC: clang" in workflow
4243
assert "CXX: clang++" in workflow
4344
assert "RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64" in workflow
44-
assert "uv run --no-sync pytest" in workflow
45-
assert "uv run --no-sync pip install" in workflow
45+
assert 'uv pip install --python "$VENV_PY"' in workflow
46+
assert 'VIRTUAL_ENV: .venv' in workflow
47+
assert '"$VENV_PY" -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml' in workflow
48+
assert '"$VENV_PY" -m pytest' in workflow
49+
50+
51+
def test_python_ci_avoids_uv_run_project_sync_for_maturin_and_pytest_steps():
52+
workflow = (_repo_root() / ".github/workflows/python.yml").read_text()
53+
assert "uv run maturin" not in workflow
54+
assert "uv run pytest" not in workflow
55+
assert "uv run --no-sync pytest" not in workflow
4656

4757

4858
def test_python_release_linux_build_targets_manylinux2014():
@@ -58,6 +68,14 @@ def test_python_release_linux_build_overrides_local_linker_and_uses_py310_abi3_b
5868
assert "CC: clang" in workflow
5969
assert "CXX: clang++" in workflow
6070
assert "--interpreter python3" in workflow
71+
assert '.venv/bin/python -m maturin build --release' in workflow
72+
assert 'export PATH=".venv/bin:$PATH"' in workflow
73+
74+
75+
def test_python_release_workflow_avoids_uv_run_project_sync():
76+
workflow = (_repo_root() / ".github/workflows/python-release.yml").read_text()
77+
assert "uv run maturin" not in workflow
78+
assert "uv run --with 'maturin[zig]'" not in workflow
6179

6280

6381
def test_infotheory_py_does_not_enable_pyo3_auto_initialize_for_extension_builds():

0 commit comments

Comments
 (0)