Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1e7b72b
Adding uv to Makefile
ciaranra Dec 14, 2024
d4e4c2c
update python-release.yml to use uv
ciaranra Dec 15, 2024
9ebe3a0
Switch to using uv.lock
ciaranra Dec 15, 2024
e9e4326
Using uv workspace
ciaranra Dec 15, 2024
073853e
Merge branch 'development' into feat/uv
ciaranra Dec 15, 2024
9c1e88e
Further makefile simplification (e.g., remove $(VENV_BIN)/)
ciaranra Dec 16, 2024
642ce76
fixing pytest-dep test path
ciaranra Dec 16, 2024
9b3457c
Tweaking makefile pytests
ciaranra Dec 16, 2024
80a2ed9
Update README and DEVELOPMENT
ciaranra Dec 16, 2024
460759c
update python-test
ciaranra Dec 16, 2024
0a7a7c2
Lint fix
ciaranra Dec 16, 2024
7e81335
python-test tweak
ciaranra Dec 16, 2024
a03b916
Update python-release
ciaranra Dec 16, 2024
114cc5e
Further tweaking python-release
ciaranra Dec 16, 2024
020e5b1
Tweak Build quantum-pecos SDist
ciaranra Dec 16, 2024
1c2d03f
More tweaking for "Build quantum-pecos SDist"
ciaranra Dec 16, 2024
16a2818
Tweak SDist
ciaranra Dec 16, 2024
4e6e460
tweak tweak
ciaranra Dec 16, 2024
38e9737
tweaks
ciaranra Dec 16, 2024
5a670a4
tqeak
ciaranra Dec 16, 2024
7adfb49
tweaakkk
ciaranra Dec 16, 2024
b15af12
Update .github/workflows/python-release.yml
ciaranra Dec 16, 2024
7aa9751
Update DEVELOPMENT.md
ciaranra Dec 16, 2024
eb0d3a8
Update README.md
ciaranra Dec 16, 2024
90cf289
update DEVELOPMENT.md
ciaranra Dec 16, 2024
8673522
Update DEVELOPMENT.md about install uv
ciaranra Dec 16, 2024
7fd6fcb
Have only one point of uv install in makefile
ciaranra Dec 16, 2024
ab70f7a
Update flows to use actions to install uv
ciaranra Dec 16, 2024
87d958c
Lint
ciaranra Dec 16, 2024
cb0b893
Fix uv nothing to cache issue
ciaranra Dec 16, 2024
cce2ae6
Removing @unset CONDA_PREFIX since likely unneeded due to uv
ciaranra Dec 17, 2024
c608600
Streamlining the discussion of `uv` in DEVELOPMENNT.md
ciaranra Dec 17, 2024
163f164
discourage installing uv via pip in Makefile
ciaranra Dec 17, 2024
e876bc3
Setting trigger to not generally create artifacts
ciaranra Dec 17, 2024
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
79 changes: 45 additions & 34 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/requirements*.txt
**/uv.lock

- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi

- name: Build pecos-rslib SDist
Expand All @@ -87,15 +94,13 @@ jobs:
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi

- name: Test pecos-rslib SDist
- name: Install and test pecos-rslib SDist
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.tar.gz
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
uv sync --project .
uv pip install --force-reinstall python/pecos-rslib/dist/*.tar.gz
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'

- name: Upload pecos-rslib SDist
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -130,13 +135,15 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi

- name: Build wheel
Expand All @@ -153,16 +160,14 @@ jobs:
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi

- name: Test wheel
if: ${{ !(matrix.architecture == 'x86_64' && matrix.os == 'macos-latest') && matrix.architecture != 'aarch64' }}
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.whl
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
uv sync --project .
uv pip install --force-reinstall python/pecos-rslib/dist/*.whl
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'

- name: Upload wheel
uses: actions/upload-artifact@v4
Expand All @@ -187,29 +192,33 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ env.PYTHON_VERSION }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
- name: Setup environment and install dependencies
run: |
python -m pip install --upgrade pip
pip install build
uv sync --project .
uv pip install ./pecos-rslib-wheel/*.whl
uv pip install build

- name: Build quantum-pecos SDist
run: |
cd python/quantum-pecos
uv pip install --system build
python -m build --sdist --outdir dist

- name: Test quantum-pecos SDist
run: |
pip install python/quantum-pecos/dist/*.tar.gz
python -c 'import pecos; print(pecos.__version__)'
uv pip install python/quantum-pecos/dist/*.tar.gz
uv run python -c 'import pecos; print(pecos.__version__)'

- name: Upload quantum-pecos SDist
uses: actions/upload-artifact@v4
Expand All @@ -233,24 +242,25 @@ jobs:
with:
ref: ${{ inputs.sha || github.sha }}

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ matrix.python-version }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
- name: Setup environment and install dependencies
run: |
python -m pip install --upgrade pip
pip install build
uv pip install --system ./pecos-rslib-wheel/*.whl build

- name: Build quantum-pecos wheel
run: |
Expand All @@ -259,8 +269,9 @@ jobs:

- name: Test quantum-pecos wheel
run: |
pip install python/quantum-pecos/dist/*.whl
python -c 'import pecos; print(pecos.__version__)'
uv sync # This will use the workspace config correctly
uv pip install python/quantum-pecos/dist/*.whl
uv run python -c 'import pecos; print(pecos.__version__)'

- name: Upload quantum-pecos wheel
uses: actions/upload-artifact@v4
Expand Down
55 changes: 24 additions & 31 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Python test / linting

on:
push:
branches: [ "master", "development" ]
Expand All @@ -22,7 +21,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


env:
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
Expand All @@ -34,7 +32,6 @@ defaults:

jobs:
python-test:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -50,25 +47,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Create and activate virtual environment
env:
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
run: |
python -m venv .venv
source .venv/$BIN/activate
echo "$GITHUB_WORKSPACE/.venv/$BIN" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install maturin pre-commit
echo "Temporarily removing pecos-rslib from requirements... because we need to build it"
grep -v "pecos-rslib" python/quantum-pecos/requirements.txt > temp_requirements.txt
echo "Installing project requirements (excluding pecos-rslib)..."
pip install -r temp_requirements.txt
echo "Cleaning up temporary files..."
rm temp_requirements.txt
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Set up Rust
run: rustup show
Expand All @@ -78,23 +60,34 @@ jobs:
with:
workspaces: python/pecos-rslib

- name: Install pecos-rslib with maturin develop
- name: Generate lockfile and install dependencies
run: |
uv lock --project .
uv sync --project .

- name: Install pecos-rslib with maturin
run: |
cd python/pecos-rslib
maturin develop
uv run maturin develop --uv

- name: Install pure Python PECOS
run: pip install ./python/quantum-pecos/
- name: Install quantum-pecos
run: |
cd python/quantum-pecos
uv pip install -e .

- name: Run pre-commit checks
run: uv run pre-commit run --all-files --show-diff-on-failure

- name: Install test dependencies
run: |
pre-commit run --all-files --show-diff-on-failure
cd python/quantum-pecos
uv pip install -e .[all,test] # Install with both all and test extras
uv pip install pytest pytest-cov # Explicitly install test requirements

- name: Run standard tests
run: |
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

- name: Run tests with optional dependencies
- name: Run optional dependency tests
run: |
pip install ./python/quantum-pecos/[all]
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
39 changes: 7 additions & 32 deletions development.md → DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,14 @@ For developers who want to contribute or modify PECOS:
cd PECOS
```

3. Set up the development environment either using the `Makefile` (Note: for Windows to use the `Makefile` you may need to use a shell that has access to Linux commands such as utilizing [git bash](https://gitforwindows.org/)):
```sh
make venv
```
<details>
<summary>or manually set up a Python virtual environment for develop of this project's code.</summary>

On Linux/Mac:

```sh
python -m venv .venv
source .venv/bin/activate
pip install -U pip setuptools
pip install -r python/quantum-pecos/requirements.txt
make metadeps
pre-commit install
```

On Windows:
3. [Install `uv` for your system](https://docs.astral.sh/uv/getting-started/installation/).
And run the following at the root of the project to create a development environment, which will be stored in `.venv/`:

```sh
python -m venv .venv
.\venv\Scripts\activate
pip install -U pip setuptools
pip install -r python/quantum-pecos/requirements.txt
make metadeps
pre-commit install
uv sync
```
</details>


4. When developing in the development environment, be sure to activate the venv:
4. You may wish to explicitly activate the environment for development. To do so:

On Linux/Mac:
```sh
Expand All @@ -50,24 +26,21 @@ For developers who want to contribute or modify PECOS:

On Windows:
```sh
.\venv\Scripts\activate
.\.venv\Scripts\activate
```


5. Build the project in editable mode
```sh
make build
```
See other build options in the `Makefile`.


6. Run all Python and Rust tests:
```sh
make test
```
Note: Make sure you have run a build command before running tests.


7. Run linters using pre-commit (after [installing it](https://pre-commit.com/)) to make sure all everything is properly linted/formated
```sh
make lint
Expand All @@ -78,4 +51,6 @@ For developers who want to contribute or modify PECOS:
deactivate
```

Before pull requests are merged, they must pass linting and the test.

Note: For the Rust side of the project, you can use `cargo` to run tests, benchmarks, formatting, etc.
Loading
Loading