Skip to content

Commit cf420fc

Browse files
authored
Refactor repo structure and CI (#17)
Now we have two projects, each in their own folder: - codetracer-pure-python-recorder -- contains the old code - codetracer-python-recorder -- contains the Rust-based module 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. We do not currently need to build and publish wheels from the CI, we only need to test them. I've removed the unnecessary steps. We'll add them once we have something to publish
2 parents a950c1f + 2a2f056 commit cf420fc

File tree

27 files changed

+377
-107
lines changed

27 files changed

+377
-107
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,43 @@ on:
99

1010
jobs:
1111
nix-tests:
12+
name: Testing on Python ${{matrix.python-version}}
1213
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.10","3.11","3.12","3.13"]
1317
steps:
1418
- uses: actions/checkout@v4
1519
- uses: cachix/install-nix-action@v27
1620
with:
1721
nix_path: nixpkgs=channel:nixos-25.05
1822
extra_nix_config: |
1923
experimental-features = nix-command flakes
20-
- name: Run tests via Nix
21-
run: nix develop --command just test
24+
- name: Build Rust module and run tests via Nix
25+
run: nix develop --command bash -lc 'just venv ${{matrix.python-version}} dev test'
2226

23-
rust-tests:
24-
name: Rust module test on ${{ matrix.os }} (Python ${{ matrix.python-version }})
25-
runs-on: ${{ matrix.os }}
26-
strategy:
27-
matrix:
28-
os: [ubuntu-latest, macos-latest, windows-latest]
29-
python-version: ["10", "11", "12", "13"]
30-
steps:
31-
- uses: actions/checkout@v4
32-
- uses: actions/setup-python@v5
33-
with:
34-
python-version: 3.${{ matrix.python-version }}
35-
- uses: astral-sh/setup-uv@v4
36-
- uses: messense/maturin-action@v1
37-
with:
38-
command: build
39-
args: --interpreter python3.${{ matrix.python-version }} -m crates/codetracer-python-recorder/Cargo.toml --release
40-
- name: Install and test built wheel with uv (pytest)
41-
shell: bash
42-
run: |
43-
v=${{matrix.python-version}}
44-
file=(crates/codetracer-python-recorder/target/wheels/*.whl)
45-
file="${file[0]}"
46-
uv run -p python3.$v --with "${file}" --with pytest -- python -m pytest crates/codetracer-python-recorder/test -q
27+
# rust-tests:
28+
# name: Rust module test on ${{ matrix.os }} (Python ${{ matrix.python-version }})
29+
# runs-on: ${{ matrix.os }}
30+
# strategy:
31+
# matrix:
32+
# os: [ubuntu-latest, macos-latest, windows-latest]
33+
# python-version: ["10", "11", "12", "13"]
34+
# steps:
35+
# - uses: actions/checkout@v4
36+
# - uses: actions/setup-python@v5
37+
# with:
38+
# python-version: 3.${{ matrix.python-version }}
39+
# - uses: astral-sh/setup-uv@v4
40+
# - uses: messense/maturin-action@v1
41+
# with:
42+
# command: build
43+
# args: --interpreter python3.${{ matrix.python-version }} -m crates/codetracer-python-recorder/Cargo.toml --release
44+
# - name: Install and test built wheel with uv (pytest)
45+
# shell: bash
46+
# run: |
47+
# v=${{matrix.python-version}}
48+
# file=(crates/codetracer-python-recorder/target/wheels/*.whl)
49+
# file="${file[0]}"
50+
# uv run -p python3.$v --with "${file}" --with pytest -- \
51+
# python -m pytest crates/codetracer-python-recorder/test tests/test_codetracer_api.py -q

Justfile

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,58 @@
1+
default:
2+
@just --list
3+
14
# Development helpers for the monorepo
25

6+
# Python version used for development
7+
PYTHON_DEFAULT_VERSION := "3.13"
8+
39
# Python versions used for multi-version testing/building with uv
410
PY_VERSIONS := "3.10 3.11 3.12 3.13"
511
PY_SHORT_VERSIONS := "10 11 12 13"
12+
613
# Print toolchain versions to verify the dev environment
714
env:
15+
uv --version
816
python3 --version
917
cargo --version
1018
rustc --version
1119
maturin --version
1220

13-
# Create a local virtualenv for Python tooling
14-
venv:
15-
test -d .venv || python3 -m venv .venv
21+
clean:
22+
rm -rf .venv **/__pycache__ **/*.pyc **/*.pyo **/.pytest_cache
23+
rm -rf codetracer-python-recorder/target codetracer-python-recorder/**/*.so
24+
1625

17-
# Build and develop-install the Rust-backed Python module
18-
build-rust:
19-
test -d .venv || python3 -m venv .venv
20-
VIRTUAL_ENV=.venv maturin develop -m crates/codetracer-python-recorder/Cargo.toml
26+
# Create a clean local virtualenv for Python tooling (without editable packages installed)
27+
venv version=PYTHON_DEFAULT_VERSION:
28+
uv sync -p {{version}}
2129

22-
# Smoke test the Rust module after build
23-
smoke-rust:
24-
.venv/bin/python -m pip install -U pip pytest
25-
.venv/bin/python -m pytest crates/codetracer-python-recorder/test -q
30+
# Build the module in dev mode
31+
dev:
32+
uv run --directory codetracer-python-recorder maturin develop --uv
2633

27-
# Run the Python test suite for the pure-Python recorder
34+
# Run unit tests of dev build
2835
test:
29-
python3 -m unittest discover -v
36+
uv run --group dev --group test pytest
3037

31-
# Run the test suite across multiple Python versions using uv
32-
test-uv-all:
33-
uv python install {{PY_VERSIONS}}
34-
for v in {{PY_VERSIONS}}; do uv run -p "$v" -m unittest discover -v; done
38+
# Run tests only on the pure recorder
39+
test-pure:
40+
uv run --group dev --group test pytest codetracer-pure-python-recorder
41+
42+
# Build the module in release mode
43+
build:
44+
just venv \
45+
uv run --directory codetracer-python-recorder maturin build --release
3546

3647
# Build wheels for all target Python versions with maturin
37-
build-rust-uv-all:
38-
for v in {{PY_VERSIONS}}; do \
39-
maturin build --interpreter "python$v" -m crates/codetracer-python-recorder/Cargo.toml --release; \
40-
done
48+
build-all:
49+
just venv
50+
uv run --directory codetracer-python-recorder maturin build --release --interpreter {{PY_VERSIONS}}
4151

4252
# Smoke the built Rust wheels across versions using uv
43-
smoke-rust-uv-all:
53+
test-all:
4454
for v in {{PY_SHORT_VERSIONS}}; do \
45-
file=(crates/codetracer-python-recorder/target/wheels/codetracer_python_recorder-*-cp3$v-cp3$v-*.whl); \
55+
file=(codetracer-python-recorder/target/wheels/codetracer_python_recorder-*-cp3$v-cp3$v-*.whl); \
4656
file="${file[0]}"; \
47-
uv run -p "python3.$v" --with "${file}" --with pytest -- python -m pytest crates/codetracer-python-recorder/test -q; \
57+
uv run -p "python3.$v" --with "${file}" --with pytest -- pytest -q; \
4858
done
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[build-system]
2+
requires = ["setuptools>=61"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "codetracer-pure-python-recorder"
7+
version = "0.1.0"
8+
description = "Pure-Python prototype recorder producing CodeTracer traces"
9+
authors = [{name = "Metacraft Labs Ltd"}]
10+
license = {text = "MIT"}
11+
readme = "README.md"
12+
requires-python = ">=3.8"
13+
classifiers = [
14+
"License :: OSI Approved :: MIT License",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3 :: Only",
17+
]
18+
19+
[tool.setuptools]
20+
py-modules = ["trace"]
21+
package-dir = {"" = "src"}
22+
23+
[tool.setuptools.packages.find]
24+
where = ["src"]
25+
26+
[project.scripts]
27+
codetracer-record = "codetracer_pure_python_recorder.cli:main"
28+
codetracer-record-pure = "codetracer_pure_python_recorder.cli:main"
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)