Skip to content

Commit ec64a90

Browse files
committed
fix: Maturin build issues
Having more than one Python interpreter in the same dev shell lead to maturin building a library with the wrong ABI version. We fixed that by unsetting PYTHONPATH. We also cleaned up the Justfile a little bit Signed-off-by: Tzanko Matev <[email protected]>
1 parent 9c9dc59 commit ec64a90

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

Justfile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,31 @@ clean:
2323
rm -rf codetracer-python-recorder/target codetracer-python-recorder/**/*.so
2424

2525

26-
# Create a local virtualenv for Python tooling
26+
# Create a clean local virtualenv for Python tooling (without editable packages installed)
2727
venv:
28-
uv venv -p python{{PYTHON_DEV_VERSION}}
28+
uv sync -p python{{PYTHON_DEV_VERSION}}
2929

30+
# Build the module in dev mode
3031
dev:
3132
just venv
3233
uv run --directory codetracer-python-recorder maturin develop --uv
3334

35+
# Run unit tests of dev build
3436
test:
35-
just venv
36-
uv run pytest
37+
uv run --group dev --group test pytest
3738

39+
# Build the module in release mode
3840
build:
39-
uv run --directory codetracer-python-recorder maturin build
40-
41-
# Run the test suite across multiple Python versions using uv
42-
test-uv-all:
43-
uv python install {{PY_VERSIONS}}
44-
for v in {{PY_VERSIONS}}; do uv run -p "$v" -m unittest discover -v; done
41+
just venv \
42+
uv run --directory codetracer-python-recorder maturin build --release
4543

4644
# Build wheels for all target Python versions with maturin
47-
build-rust-uv-all:
48-
for v in {{PY_VERSIONS}}; do \
49-
uv run -p "$v" --directory codetracer-python-recorder maturin build --release; \
50-
done
45+
build-all:
46+
just venv
47+
uv run --directory codetracer-python-recorder maturin build --release --interpreter {{PY_VERSIONS}}
5148

5249
# Smoke the built Rust wheels across versions using uv
53-
test-rust-uv-all:
50+
test-all:
5451
for v in {{PY_SHORT_VERSIONS}}; do \
5552
file=(codetracer-python-recorder/target/wheels/codetracer_python_recorder-*-cp3$v-cp3$v-*.whl); \
5653
file="${file[0]}"; \

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
ruff
2626
black
2727
mypy
28-
python3Packages.pytest
2928

3029
# Rust toolchain for the Rust-backed Python module
3130
cargo
@@ -38,6 +37,12 @@
3837
uv
3938
pkg-config
4039
];
40+
41+
shellHook = ''
42+
# When having more than one python version in the shell this variable breaks `maturin build`
43+
# because it always leads to having SOABI be the one from the highest version
44+
unset PYTHONPATH
45+
'';
4146
};
4247
});
4348
};

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ typeCheckingMode = "basic"
2626
[dependency-groups]
2727
dev = [
2828
"pytest>=8.3.5",
29-
"codetracer-python-recorder",
30-
"codetracer-pure-python-recorder"
3129
]
3230

31+
test = [
32+
"codetracer-python-recorder",
33+
"codetracer-pure-python-recorder"
34+
]

uv.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)