Skip to content

Commit b9dbb52

Browse files
Migrate from Poetry to uv (#525)
* Migrate from Poetry to uv * fix pypi metadata with uv * Updating contribution for uv * Nox and uv integration upgrades (#1) * WIP: nox with uv pipelines * WIP: Enforce uv setup venv * WIP: Force uv to use sessions interpreter * Drop python-version for coverage to conform with current requirements * pin labeler to 5.0.0 * revert labeler pin * only install pre-commit deps; not all dev * don't install all dev reqs in mypy * remove redundant installs * remove root package install from coverage report * add toml extra to coverage * remove dev installs from typeguard and xdoctest, add color extra * remove dev reqs install from docs * we aren't using hatch, so remove tool config * remove commented out hatch build backend * reorg pyproject.toml * lint * use uv for venv creation * lint * resolve uv venv not being picked up * Removing vestigial temp file * update to safety v3 cli usage * add safety auth * revert safety v3 * update requirements for safety * shorten line 181 * lint and fix * add env --------- Co-authored-by: Altay Sansal <tasansal@users.noreply.github.com>
1 parent db741ea commit b9dbb52

File tree

9 files changed

+3536
-5097
lines changed

9 files changed

+3536
-5097
lines changed

.github/workflows/constraints-poetry.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/constraints.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
pip==25.0.1
1+
bump-my-version==1.1.1
22
nox==2025.2.9
3-
nox-poetry==1.2.0
4-
virtualenv==20.29.2

.github/workflows/release.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,40 @@ jobs:
1616
with:
1717
fetch-depth: 2
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
19+
- name: Install the pinned version of uv
20+
uses: astral-sh/setup-uv@v5
2121
with:
22-
python-version: "3.12"
22+
python-version: 3.13
23+
pyproject-file: "${{ github.workspace }}/pyproject.toml"
2324

24-
- name: Upgrade pip
25+
- name: Install bumpversion
2526
run: |
26-
pip install --constraint=.github/workflows/constraints.txt pip
27-
pip --version
28-
29-
- name: Install Poetry
30-
run: |
31-
pip install --constraint=.github/workflows/constraints-poetry.txt poetry
32-
poetry --version
27+
uv tool install --constraint=.github/workflows/constraints.txt bump-my-version
28+
bump-my-version --version
3329
3430
- name: Check if there is a parent commit
3531
id: check-parent-commit
3632
run: |
37-
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
33+
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
3834
3935
- name: Detect and tag new version
4036
id: check-version
4137
if: steps.check-parent-commit.outputs.sha
4238
uses: salsify/action-detect-and-tag-new-version@v2.0.3
4339
with:
4440
version-command: |
45-
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
41+
bump-my-version show current_version
4642
4743
- name: Bump version for developmental release
4844
if: "! steps.check-version.outputs.tag"
4945
run: |
50-
poetry version patch &&
51-
version=$(poetry version | awk '{ print $2 }') &&
52-
poetry version $version.dev.$(date +%s)
46+
bump-my-version bump patch &&
47+
version=$(bump-my-version show current_version) &&
48+
bump-my-version bump --new-version $version.dev$(date +%s)
5349
5450
- name: Build package
5551
run: |
56-
poetry build --ansi
52+
uv build
5753
5854
- name: Publish package on PyPI
5955
if: steps.check-version.outputs.tag

.github/workflows/tests.yml

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,15 @@ jobs:
4242
with:
4343
python-version: ${{ matrix.python }}
4444

45-
- name: Upgrade pip
46-
run: |
47-
pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip
48-
pip --version
49-
50-
- name: Upgrade pip in virtual environments
51-
shell: python
52-
run: |
53-
import os
54-
import pip
55-
56-
with open(os.environ["GITHUB_ENV"], mode="a") as io:
57-
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
58-
59-
- name: Install Poetry
60-
run: |
61-
pipx install --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints-poetry.txt" poetry
62-
pipx inject poetry poetry-plugin-export
63-
poetry --version
45+
- name: Install the pinned version of uv
46+
uses: astral-sh/setup-uv@v5
47+
with:
48+
python-version: ${{ matrix.python }}
49+
pyproject-file: ${{ github.workspace }}/pyproject.toml
6450

6551
- name: Install Nox
6652
run: |
67-
pipx install --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox
68-
pipx inject --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry
53+
uv tool install -c "${{ github.workspace }}/.github/workflows/constraints.txt" nox
6954
nox --version
7055
7156
- name: Compute pre-commit cache key
@@ -75,13 +60,14 @@ jobs:
7560
run: |
7661
import hashlib
7762
import sys
63+
import os
7864
7965
python = "py{}.{}".format(*sys.version_info[:2])
8066
payload = sys.version.encode() + sys.executable.encode()
8167
digest = hashlib.sha256(payload).hexdigest()
8268
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
8369
84-
print("::set-output name=result::{}".format(result))
70+
print("result={}".format(result), file=open(os.environ['GITHUB_OUTPUT'], 'a'))
8571
8672
- name: Restore pre-commit cache
8773
uses: actions/cache@v4
@@ -118,26 +104,15 @@ jobs:
118104
- name: Check out the repository
119105
uses: actions/checkout@v4
120106

121-
- name: Set up Python
122-
uses: actions/setup-python@v5
107+
- name: Install the pinned version of uv
108+
uses: astral-sh/setup-uv@v5
123109
with:
124-
python-version: "3.12"
125-
126-
- name: Upgrade pip
127-
run: |
128-
pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip
129-
pip --version
130-
131-
- name: Install Poetry
132-
run: |
133-
pipx install --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints-poetry.txt" poetry
134-
pipx inject poetry poetry-plugin-export
135-
poetry --version
110+
python-version: 3.12
111+
pyproject-file: "${{ github.workspace }}/pyproject.toml"
136112

137113
- name: Install Nox
138114
run: |
139-
pipx install --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox
140-
pipx inject --pip-args="-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry
115+
uv tool install -c "${{ github.workspace }}/.github/workflows/constraints.txt" nox
141116
nox --version
142117
143118
- name: Download coverage data
@@ -155,6 +130,6 @@ jobs:
155130
nox --session=coverage -- xml
156131
157132
- name: Upload coverage report
158-
uses: codecov/codecov-action@v5
133+
uses: codecov/codecov-action@v5.1.2
159134
env:
160135
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

CONTRIBUTING.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ Request features on the [Issue Tracker].
3939

4040
You need Python 3.10+ and the following tools:
4141

42-
- [Poetry]
42+
- [uv]
4343
- [Nox]
44-
- [nox-poetry]
4544

4645
Another alternative is to use a [Development Container] has been setup to provide
4746
an environment with the required dependencies. This facilitates development on
@@ -55,23 +54,22 @@ This should seamlessly enable development for users of [VS Code] on systems with
5554

5655
## How to Install and Run MDIO
5756

58-
Install the package with development requirements:
57+
Install the package with development and documentation generation requirements:
5958

6059
```console
61-
$ poetry install
60+
$ uv sync --all-groups
6261
```
6362

6463
You can now run an interactive Python session,
6564
or the command-line interface:
6665

6766
```console
68-
$ poetry run python
69-
$ poetry run mdio
67+
$ uv run python
68+
$ uv run mdio
7069
```
7170

72-
[poetry]: https://python-poetry.org/
71+
[uv]: https://docs.astral.sh/uv/
7372
[nox]: https://nox.thea.codes/
74-
[nox-poetry]: https://nox-poetry.readthedocs.io/
7573
[development container]: https://containers.dev/
7674
[vs code]: https://code.visualstudio.com/docs/devcontainers/containers/
7775

0 commit comments

Comments
 (0)