Skip to content

Commit dbd65af

Browse files
committed
Fix?
1 parent 793f74c commit dbd65af

4 files changed

Lines changed: 48 additions & 71 deletions

File tree

.github/workflows/python-test.yml

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,25 @@ jobs:
103103
# Export UV_PYTHON for all subsequent steps
104104
echo "UV_PYTHON=$PYTHON_PATH" >> "$GITHUB_ENV"
105105
106-
- name: Generate lockfile and install dependencies
106+
- name: Create virtual environment
107107
run: |
108-
# Create venv - uv should now use UV_PYTHON
109-
uv venv
108+
# Create venv using the correct Python version from setup-python
109+
uv venv --python "$UV_PYTHON"
110110
111111
# Verify the venv is using the correct Python version
112112
echo "Python in venv:"
113-
uv run python --version
113+
source .venv/bin/activate
114+
python --version
114115
115116
# Verify version matches what we expect
116-
VENV_PYTHON_VERSION=$(uv run python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
117+
VENV_PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
117118
if [[ "$VENV_PYTHON_VERSION" != "${{ matrix.python-version }}" ]]; then
118119
echo "ERROR: Python version mismatch!"
119120
echo "Expected: ${{ matrix.python-version }}"
120121
echo "Got: $VENV_PYTHON_VERSION"
121122
exit 1
122123
fi
123124
124-
# Skip sync as it creates wrong Python version
125-
# Just ensure the venv is created with correct Python
126-
127125
- name: Fix SQLite for macOS Python 3.13
128126
if: ${{ matrix.os == 'macOS-latest' && matrix.python-version == '3.13' }}
129127
run: |
@@ -159,58 +157,14 @@ jobs:
159157
echo "except ImportError:" >> "$SITE_PACKAGES/sitecustomize.py"
160158
echo " pass" >> "$SITE_PACKAGES/sitecustomize.py"
161159
162-
- name: Install pecos rng build dependencies
163-
run: |
164-
uv pip install build nanobind scikit-build-core cmake ninja
165-
166-
- name: Build PECOS RNG
167-
run: |
168-
cd clib/pecos-rng
169-
# On macOS and Windows, use system compiler instead of LLVM for C++ extensions
170-
if [[ "${{ matrix.os }}" == "macOS-latest" ]] || [[ "${{ runner.os }}" == "Windows" ]]; then
171-
unset CC CXX
172-
fi
173-
uv pip install .
174-
175-
- name: Install pecos-rslib with maturin
176-
run: |
177-
cd python/pecos-rslib
178-
# On macOS and Windows, use system compiler for C dependencies in Rust crates
179-
if [[ "${{ matrix.os }}" == "macOS-latest" ]] || [[ "${{ runner.os }}" == "Windows" ]]; then
180-
unset CC CXX
181-
fi
182-
uv run maturin develop --uv
183-
184-
- name: Install quantum-pecos and dependencies
160+
- name: Build PECOS
185161
run: |
186-
# First install the core dependencies
187-
uv pip install numpy scipy networkx matplotlib phir
188-
# Then install quantum-pecos in editable mode
189-
cd python/quantum-pecos
190-
uv pip install -e .
191-
# Verify installation
192-
echo "Checking installed packages:"
193-
uv pip list | grep -E "(numpy|scipy|networkx|matplotlib|phir|pecos|quantum)" || true
162+
# Use the Makefile to build everything, respecting existing venv
163+
UV_PYTHON="$UV_PYTHON" make build
194164
195165
- name: Run pre-commit checks
196166
run: uv run pre-commit run --all-files --show-diff-on-failure
197167

198-
- name: Install test dependencies
199-
run: |
200-
cd python/quantum-pecos
201-
# For Linux, unset CC/CXX to avoid LLVM LTO issues with llvmlite
202-
if [[ "${{ runner.os }}" == "Linux" ]]; then
203-
unset CC CXX
204-
fi
205-
206-
# Disable LTO for llvmlite build to avoid gold linker requirement
207-
export CFLAGS="-fno-lto"
208-
export CXXFLAGS="-fno-lto"
209-
export LDFLAGS="-fno-lto"
210-
export LLVMLITE_SKIP_LLVM_VERSION_CHECK=1
211-
212-
uv pip install -e .[all,test] # Install with both all and test extras
213-
uv pip install pytest pytest-cov # Explicitly install test requirements
214168

215169
- name: Debug environment
216170
run: |
@@ -227,19 +181,14 @@ jobs:
227181
uv run python -c "import sys; print('Python paths:'); print('\n'.join(sys.path))"
228182
uv run python -c "import numpy; print('numpy imported successfully')" || echo "Failed to import numpy"
229183
uv run python -c "import networkx; print('networkx imported successfully')" || echo "Failed to import networkx"
184+
uv run python -c "import pecos; print('pecos imported successfully')" || echo "Failed to import pecos"
230185
231186
- name: Run standard tests
232187
run: |
233-
# Ensure dependencies are installed
234-
uv pip install numpy scipy networkx matplotlib phir pytest pytest-cov
235-
# Set PYTHONPATH to include both quantum-pecos and pecos-rslib src
236-
export PYTHONPATH="$(pwd)/python/quantum-pecos/src:$(pwd)/python/pecos-rslib/src:${PYTHONPATH}"
237-
# Run tests
238-
uv run pytest python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=pecos --cov-report=xml --cov-report=html
188+
# Use the Makefile to run standard Python tests (now includes PYTHONPATH)
189+
make pytest
239190
240191
- name: Run optional dependency tests
241192
run: |
242-
# Set PYTHONPATH to include both quantum-pecos and pecos-rslib src
243-
export PYTHONPATH="$(pwd)/python/quantum-pecos/src:$(pwd)/python/pecos-rslib/src:${PYTHONPATH}"
244-
# Run optional dependency tests
245-
uv run pytest python/tests --doctest-modules --junitxml=junit/test-results-optional.xml --cov=pecos --cov-report=xml --cov-report=html -m optional_dependency
193+
# Use the Makefile to run optional dependency tests (now includes PYTHONPATH)
194+
make pytest-dep

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ updatereqs: ## Generate/update lockfiles for both packages
1717
.PHONY: installreqs
1818
installreqs: ## Install Python project requirements to root .venv
1919
@echo "Installing requirements..."
20-
uv sync
20+
@if [ -n "$(UV_PYTHON)" ]; then \
21+
echo "Using pinned Python: $(UV_PYTHON)"; \
22+
uv sync --python "$(UV_PYTHON)"; \
23+
else \
24+
uv sync; \
25+
fi
2126

2227
.PHONY: buildrng
2328
buildrng:
2429
@echo "Building and installing RNG library..."
2530
uv pip install nanobind
26-
cd clib/pecos-rng && CC=gcc CXX=g++ uv pip install --python $(shell uv run which python) -e .
31+
cd clib/pecos-rng && CC=gcc CXX=g++ uv pip install -e .
2732

2833
# Building development environments
2934
# ---------------------------------
@@ -174,12 +179,12 @@ decoder-cache-clean: ## Clean decoder download cache
174179

175180
.PHONY: pytest
176181
pytest: ## Run tests on the Python package (not including optional dependencies). ASSUMES: previous build command
177-
uv run pytest ./python/tests/ -m "not optional_dependency"
178-
uv run pytest ./python/pecos-rslib/tests/
182+
PYTHONPATH="$(PWD)/python/quantum-pecos/src:$(PWD)/python/pecos-rslib/src:$(PYTHONPATH)" uv run pytest ./python/tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=pecos --cov-report=xml --cov-report=html -m "not optional_dependency"
183+
PYTHONPATH="$(PWD)/python/quantum-pecos/src:$(PWD)/python/pecos-rslib/src:$(PYTHONPATH)" uv run pytest ./python/pecos-rslib/tests/
179184

180185
.PHONY: pytest-dep
181186
pytest-dep: ## Run tests on the Python package only for optional dependencies. ASSUMES: previous build command
182-
uv run pytest ./python/tests/ -m optional_dependency
187+
PYTHONPATH="$(PWD)/python/quantum-pecos/src:$(PWD)/python/pecos-rslib/src:$(PYTHONPATH)" uv run pytest ./python/tests/ --doctest-modules --junitxml=junit/test-results-optional.xml --cov=pecos --cov-report=xml --cov-report=html -m optional_dependency
183188

184189
.PHONY: pytest-all
185190
pytest-all: pytest ## Run all tests on the Python package ASSUMES: previous build command

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ dev = [
2020
"mkdocs-material", # Material theme for MkDocs
2121
"mkdocstrings[python]", # Code documentation extraction
2222
"markdown-exec[ansi]", # Executable markdown blocks
23+
# Runtime dependencies for development
24+
"numpy>=1.15.0",
25+
"scipy>=1.1.0",
26+
"networkx>=2.1.0",
27+
"matplotlib>=2.2.0",
28+
"phir>=0.3.3",
29+
# Optional dependencies for testing
30+
"llvmlite==0.41.0",
2331
]
2432
test = [ # pinning testing environment
2533
"pytest==8.3.3", # 8.3.4 seems to be causing errors

uv.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)