Skip to content

Commit 9ed0b61

Browse files
authored
feat: switch from poetry to uv (#561)
* feat: switch from poetry to uv * chore: update workflows to also use uv instead of poetry. * chore: update workflows to also use uv instead of poetry. * chore: update workflows to also use uv instead of poetry. * chore: update workflows to also use uv instead of poetry. * chore: update workflows to also use uv instead of poetry. * chore: update workflows to also use uv instead of poetry. * chore: update test coverage * docs: simplify dev guide install * chore: keeping the same qedc algs from pyproject.toml on main. * chore: using uv build
1 parent aa17c6d commit 9ed0b61

File tree

8 files changed

+3332
-6257
lines changed

8 files changed

+3332
-6257
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ jobs:
2525
with:
2626
python-version: "3.12"
2727

28-
- name: Install Poetry
29-
uses: snok/install-poetry@v1
28+
- name: Set up uv
29+
uses: astral-sh/setup-uv@v1
3030
with:
31-
virtualenvs-create: true
32-
virtualenvs-in-project: true
31+
version: "0.8.22"
3332

34-
- name: Install dependencies
35-
run: poetry install --no-interaction --no-root
33+
- name: Sync dependencies
34+
run: uv sync --group dev --frozen
3635

3736
- name: Build package
38-
run: poetry build
37+
run: uv build
3938

4039
- name: Publish package distributions to PyPI
4140
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/publish-to-testpypi.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ jobs:
2525
with:
2626
python-version: "3.12"
2727

28-
- name: Install Poetry
29-
uses: snok/install-poetry@v1
28+
- name: Set up uv
29+
uses: astral-sh/setup-uv@v1
3030
with:
31-
virtualenvs-create: true
32-
virtualenvs-in-project: true
31+
version: "0.8.22"
3332

34-
- name: Install dependencies
35-
run: poetry install --no-interaction --no-root
33+
- name: Sync dependencies
34+
run: uv sync --group dev --frozen
3635

3736
- name: Build package
38-
run: poetry build
37+
run: uv build
3938

4039
- name: Publish package distributions to TestPyPI
4140
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will install Python dependencies, run tests, type checking with mypy and lint with Ruff and Poetry.
1+
# This workflow installs Python dependencies, runs tests, type checks with mypy, and lints with Ruff using uv.
22
# It can be tested locally using https://github.com/nektos/act with the command `act push --container-architecture linux/amd64 -j build`
33

44
name: Python Tests
@@ -44,35 +44,30 @@ jobs:
4444
with:
4545
python-version: ${{ matrix.python-version }}
4646

47-
- name: Install Poetry
48-
run: |
49-
python -m pip install --upgrade pip
50-
pip install poetry
47+
- name: Set up uv
48+
uses: astral-sh/setup-uv@v1
49+
with:
50+
version: "0.8.22"
5151

5252
- name: Initialize and update submodules
5353
run: |
5454
git submodule update --init --recursive
5555
56-
- name: Install project *dependencies only*
56+
- name: Sync dependencies
5757
run: |
58-
poetry install --no-root
58+
uv sync --group dev --frozen
5959
6060
- name: Lint with Ruff
6161
run: |
62-
poetry run ruff check
62+
uv run ruff check
6363
6464
- name: Type checking with MyPy
6565
# Running mypy with numpy > 2.0 is broken.
6666
# This is a fix for stubgen: https://github.com/python/mypy/issues/17396
6767
run: |
68-
poetry run stubgen --no-analysis
69-
poetry run mypy
70-
71-
- name: Install project and CLI command
72-
run: |
73-
poetry install
68+
uv run stubgen --no-analysis
69+
uv run mypy
7470
7571
- name: Run tests
7672
run: |
77-
poetry run pytest
78-
73+
uv run pytest

CONTRIBUTING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ Thanks for your interest in improving the project! This guide describes how to g
44

55
## Getting started
66

7-
1. Install Python 3.12 or newer and [Poetry](https://python-poetry.org/docs/#installation).
7+
1. Install Python 3.12 or newer and [uv](https://docs.astral.sh/uv/getting-started/installation/).
88
2. Clone the repository with submodules:
99
```sh
1010
git clone --recurse-submodules https://github.com/unitaryfoundation/metriq-gym.git
1111
cd metriq-gym
1212
```
1313
3. Install dependencies and activate the virtual environment:
1414
```sh
15-
poetry install
16-
poetry shell # or eval "$(poetry env activate)"
15+
uv sync --all-groups
16+
source .venv/bin/activate # or use `uv run` for one-off commands
1717
```
1818
4. Install the pre-commit hooks so linting and type checks run automatically:
1919
```sh
20-
poetry run pre-commit install
20+
uv run pre-commit install
2121
```
2222

2323
## Development workflow
2424

25-
- Use `poetry run mgym --help` to confirm the CLI is wired correctly after changes.
25+
- Use `uv run mgym --help` to confirm the CLI is wired correctly after changes.
2626
- Keep provider credentials in a local `.env` copied from `.env.example`; never commit secrets.
27-
- When touching schemas or benchmark examples, validate them with `poetry run mgym job dispatch ...` using a local simulator before opening a PR.
27+
- When touching schemas or benchmark examples, validate them with `uv run mgym job dispatch ...` using a local simulator before opening a PR.
2828

2929
## Coding standards
3030

3131
- Follow the defaults enforced by Ruff: 4-space indentation and 100-character lines.
32-
- Run `poetry run ruff check --fix` and `poetry run ruff format` before committing.
33-
- Maintain or extend type hints and verify them with `poetry run mypy`.
32+
- Run `uv run ruff check --fix` and `uv run ruff format` before committing.
33+
- Maintain or extend type hints and verify them with `uv run mypy`.
3434
- Add concise, purposeful docstrings; avoid large dumps of commented-out code.
3535
- Keep provider-specific logic inside the relevant subpackage (`local/`, `quantinuum/`, `qplatform/`).
3636

@@ -39,9 +39,9 @@ Thanks for your interest in improving the project! This guide describes how to g
3939
Run the relevant test suites prior to submission:
4040

4141
```sh
42-
poetry run pytest tests/unit # fast coverage
43-
poetry run pytest -m e2e # CLI workflows (run before merging)
44-
poetry run pytest # full suite when feasible
42+
uv run pytest tests/unit # fast coverage
43+
uv run pytest -m e2e # CLI workflows (run before merging)
44+
uv run pytest # full suite when feasible
4545
```
4646

4747
For features that add new benchmark payloads or alter CLI flows, update fixtures in `jobs/` and document the change in the `CLI Workflows` guide under `docs/source/` if appropriate.

docs/source/developer_guide.rst

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Prerequisites
1414
Before you begin, ensure you have the following installed:
1515

1616
* `Python <https://www.python.org/downloads/>`_ (version 3.12 or newer)
17-
* `Poetry <https://python-poetry.org/docs/#installation>`_ for managing dependencies
17+
* `uv <https://docs.astral.sh/uv/getting-started/installation/>`_ for managing dependencies
1818

1919
Cloning the Repository
2020
----------------------
@@ -35,25 +35,15 @@ If you already have a local clone (with or without submodules), keep it current
3535
Installation
3636
------------
3737

38-
Install dependencies into the Poetry-managed virtual environment:
38+
Install dependencies into the uv-managed virtual environment:
3939

4040
.. code-block:: sh
4141
42-
poetry install
42+
uv sync --all-groups
4343
44-
We recommend working inside an isolated environment. See `Poetry documentation
45-
<https://python-poetry.org/docs/managing-environments/>`_ for tips on managing virtual environments.
46-
47-
For ``pyenv`` users, the following commands configure Python and install dependencies:
48-
49-
.. code-block:: sh
50-
51-
pyenv install 3.13
52-
pyenv local 3.13
53-
poetry install
54-
eval $(poetry env activate)
55-
56-
Run all subsequent Python commands inside the activated environment.
44+
``uv`` reads the Python requirement from ``pyproject.toml`` and provisions a compatible interpreter automatically.
45+
After ``uv sync`` the project environment lives in ``.venv``; activate it with ``source .venv/bin/activate`` if you
46+
prefer a shell-based workflow, or continue using ``uv run`` for isolated commands.
5747

5848
Contributing
5949
------------
@@ -67,7 +57,7 @@ Run the linter and formatter before each commit. Install the pre-commit hooks ri
6757

6858
.. code-block:: sh
6959
70-
poetry run pre-commit install
60+
uv run pre-commit install
7161
7262
Tests
7363
-----
@@ -76,19 +66,19 @@ The entire suite of tests can be run with
7666

7767
.. code-block:: sh
7868
79-
poetry run pytest
69+
uv run pytest
8070
8171
Unit tests only can be run with
8272

8373
.. code-block:: sh
8474
85-
poetry run pytest -m "not e2e"
75+
uv run pytest -m "not e2e"
8676
8777
End-to-end tests only can be run with
8878

8979
.. code-block:: sh
9080
91-
poetry run pytest -m e2e
81+
uv run pytest -m e2e
9282
9383
Type Checking
9484
-------------
@@ -98,7 +88,7 @@ command:
9888

9989
.. code-block:: sh
10090
101-
poetry run mypy
91+
uv run mypy
10292
10393
Documentation
10494
-------------
@@ -109,7 +99,7 @@ inside the ``docs`` directory:
10999
.. code-block:: sh
110100
111101
cd docs
112-
poetry run make html
102+
uv run make html
113103
114104
Open ``_build/html/index.html`` to view the render locally.
115105

0 commit comments

Comments
 (0)