Skip to content

Commit 4e21868

Browse files
committed
chore!: adopt uv and PEP 735 dependency groups
Move the development dependencies from [tool.pdm.dev-dependencies] to the standard [dependency-groups] table and lock them with uv (uv.lock). Drop pdm.lock and the exported package/requirements.*.txt files, which CI and the release script consumed. - CI installs with `uv sync --locked` instead of `pip install -r`. - package/export builds with `uv build` instead of `pdm build`. - package/roll.sh and roll.ps1 run the export in a throwaway uv environment. - CONTRIBUTING.md documents the uv workflow.
1 parent cd6facb commit 4e21868

13 files changed

Lines changed: 1527 additions & 2137 deletions

‎.github/workflows/docs.yaml.bkp‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@ jobs:
1111
contents: read
1212
env:
1313
BUILD_PATH: .
14-
PIP_DISABLE_PIP_VERSION_CHECK: 1
1514
steps:
1615
# checkout repository
1716
- name: Checkout repository
1817
uses: actions/checkout@v4
19-
# set up specific python version
20-
- name: Set up Python v3.12
21-
uses: actions/setup-python@v5
18+
# set up uv and a specific python version
19+
- name: Set up uv with Python v3.12
20+
uses: astral-sh/setup-uv@v10.3.0
2221
with:
2322
python-version: "3.12"
2423
# building
2524
- name: Install 'documentation' dependencies
26-
run: |
27-
pip install .
28-
pip install -r package/requirements.mkdocs.txt
25+
run: uv sync --locked --no-editable --group docs-online --extra crypto-eth-addresses
2926
- name: Build documentation
30-
run: python package/export doc
27+
run: uv run --no-sync python package/export doc
3128
# set up Pages
3229
- name: Set up Pages
3330
uses: actions/configure-pages@v4

‎.github/workflows/package.yaml.bkp‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,20 @@ jobs:
1212
contents: read
1313
env:
1414
BUILD_PATH: .
15-
PIP_DISABLE_PIP_VERSION_CHECK: 1
1615
steps:
1716
# checkout repository
1817
- name: Checkout repository
1918
uses: actions/checkout@v4
20-
# set up specific python version
21-
- name: Set up Python v3.8
22-
uses: actions/setup-python@v5
19+
# set up uv and a specific python version
20+
- name: Set up uv with Python v3.11
21+
uses: astral-sh/setup-uv@v10.3.0
2322
with:
24-
python-version: "3.8"
25-
# install dependencies
26-
- name: Install dependencies
27-
run: |
28-
python -m venv .venv
29-
./.venv/bin/python -m pip install --upgrade pip
30-
./.venv/bin/pip install .
31-
./.venv/bin/pip install -r package/requirements.sphinx.txt
32-
./.venv/bin/pip install build
33-
# build package
23+
python-version: "3.11"
24+
# build package (generates the man page, then runs `uv build`)
3425
- name: Build package
3526
run: |
36-
. ./.venv/bin/activate
37-
python package/export pkg
38-
deactivate
27+
uv run --locked --no-editable --group docs-offline --extra crypto-eth-addresses \
28+
python package/export pkg
3929
# upload package as artifact
4030
- name: Upload artifact
4131
uses: actions/upload-pages-artifact@v3

‎.github/workflows/pycqa.yaml‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@ on:
99
jobs:
1010
tooling:
1111
runs-on: ubuntu-latest
12-
env:
13-
PIP_DISABLE_PIP_VERSION_CHECK: 1
1412
steps:
1513
# checkout repository
1614
- name: Checkout repository
1715
uses: actions/checkout@v6
18-
# set up specific python version
19-
- name: Set up Python v3.11
20-
uses: actions/setup-python@v6
16+
# set up uv and a specific python version
17+
- name: Set up uv with Python v3.11
18+
uses: astral-sh/setup-uv@v10.3.0
2119
with:
2220
python-version: "3.11"
21+
enable-cache: true
2322
# tooling
2423
- name: Install 'tooling' dependencies
25-
run: pip install -r package/requirements.tooling.txt
24+
run: uv sync --locked --group tooling --extra crypto-eth-addresses
2625
- name: Tooling
2726
run: |
28-
ruff format .
29-
ruff check .
30-
pyright .
27+
uv run --no-sync ruff format .
28+
uv run --no-sync ruff check .
29+
uv run --no-sync pyright .
3130
testing:
3231
strategy:
3332
fail-fast: true
@@ -40,16 +39,14 @@ jobs:
4039
# ref: https://github.com/actions/checkout/issues/19
4140
- name: Checkout repository
4241
uses: actions/checkout@v4
43-
# set up specific python version
44-
- name: Set up Python v${{ matrix.python-version }}
45-
uses: actions/setup-python@v5
42+
# set up uv and a specific python version
43+
- name: Set up uv with Python v${{ matrix.python-version }}
44+
uses: astral-sh/setup-uv@v10.3.0
4645
with:
4746
python-version: ${{ matrix.python-version }}
48-
cache: "pip"
47+
enable-cache: true
4948
# testing
5049
- name: Install 'testing' dependencies
51-
run: |
52-
pip install -r package/requirements.testing.txt
53-
pip install .
50+
run: uv sync --locked --no-editable --group testing --extra crypto-eth-addresses
5451
- name: Testing
55-
run: pytest .
52+
run: uv run --no-sync pytest .

‎CONTRIBUTING.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Hi, to start, you need the following installed on your system.
44

55
1. [Git](https://git-scm.com)
6-
2. [Python](https://www.python.org) v3.8 or later
7-
3. [PDM](https://pdm-project.org) for easy dependency management
6+
2. [Python](https://www.python.org) v3.11 or later
7+
3. [uv](https://docs.astral.sh/uv/) for dependency management
88
4. (Optional/Recommended) [`NodeJS`](https://nodejs.org/en) for type checking
99
5. (Optional/Recommended) [`mise`](https://github.com/jdx/mise) to manage multiple versions of Python, NodeJS and other such tools.
1010

@@ -16,18 +16,18 @@ $ git clone "https://github.com/YOUR-USERNAME/validators.git"
1616
# change directory
1717
$ cd validators
1818
# install development dependencies
19-
$ pdm install
19+
$ uv sync --group testing --group tooling --group runner --extra crypto-eth-addresses
2020
```
2121

22-
Activate the virtual environment and run `tox` to verify test cases.
22+
Run `tox` to verify test cases. (`uv run` uses the project's virtual environment, so you don't need to activate it.)
2323

2424
```sh
25-
# activate virtual environment
26-
$ . ./.venv/bin/activate # replace `/bin/` with `/Scripts/` if you're on Windows.
2725
# run tox for linting, type checking, formatting etc.
28-
$ tox
26+
$ uv run tox
2927
```
3028

29+
Development dependencies are declared as [dependency groups](https://packaging.python.org/en/latest/specifications/dependency-groups/) in `pyproject.toml` (`testing`, `tooling`, `runner`, `docs-offline`, `docs-online`, `package` and `sast`) and are locked in `uv.lock`. Run `uv lock --upgrade` to update them, and commit `uv.lock`.
30+
3131
Create a git branch and make changes to the source code. If needed, test your changes by running `pytest`. Execute `tox` to format, lint and type-check your code before committing. Commit, push and create a pull request. If you're in doubt, feel free to start a discussion [here](https://github.com/python-validators/validators/discussions).
3232

3333
## Documentation
@@ -38,9 +38,10 @@ If you're adding/removing a module, you must update the `nav` key in `mkdocs.yml
3838
Then export documentation as follows:
3939

4040
```sh
41-
$ . ./.venv/bin/activate
41+
# install documentation dependencies
42+
$ uv sync --group docs-offline --group docs-online --extra crypto-eth-addresses
4243
# generate documentation
43-
$ python package/export TYPE # where TYPE is any of `doc`, `man` or `web`.
44+
$ uv run python package/export TYPE # where TYPE is any of `doc`, `man` or `web`.
4445

4546
# doc - generates docs found here: https://nandgator.github.io/pyvalidators
4647
# man - generates sphinx based manpages
@@ -50,9 +51,8 @@ $ python package/export TYPE # where TYPE is any of `doc`, `man` or `web`.
5051
You can preview the generated documentation:
5152

5253
```sh
53-
$ . ./.venv/bin/activate
5454
# To preview mkdocs
55-
$ mkdocs serve
55+
$ uv run mkdocs serve
5656
# To preview man pages
5757
$ man docs/_build/man/validators.1
5858
# To preview sphinx webpages
@@ -82,15 +82,15 @@ $ python -m http.server -d docs/_build/web
8282

8383
### Versioned documentation
8484

85-
1. To preview versioned docs, run `mike serve` (`mike` is a dev dependency).
85+
1. To preview versioned docs, run `uv run mike serve` (`mike` is in the `docs-online` dependency group).
8686
2. Then (look at <https://nandgator.github.io/pyvalidators/stable/>)
8787
- to publish stable docs run `mike deploy -p -u VERSION stable` after checking out to a stable tag name like `0.28.3` (note: document `VERSION = 0.29 if tag_name == 0.29.1`).
8888
- to publish bleeding-edge docs run `mike deploy -p -u dev master` after checking out to the `master` branch.
8989
3. This will deploy docs to the `gh-pages` branch (see: <https://github.com/python-validators/validators/tree/gh-pages/>)
9090
9191
### Packaging and releasing
9292
93-
1. Run `./package/roll.sh` (or `./package/roll.ps1`) to generate both `sdist` and `bdist`.
93+
1. Run `./package/roll.sh` (or `./package/roll.ps1`) to generate the man page and both `sdist` and `bdist` (it needs [uv](https://docs.astral.sh/uv/) and uses the locked `docs-offline` dependencies).
9494
2. Install [`twine`](https://pypi.org/project/twine) using [`pipx`](https://pipx.pypa.io) to upload package to PyPI.
9595
9696
```sh

‎package/export/__main__.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# standard
44
from ast import ImportFrom, parse
5-
from os import getenv
65
from os.path import getsize
76
from pathlib import Path
87
from shutil import copy
@@ -144,10 +143,7 @@ def _generate_documentation(
144143
def package(source: Path):
145144
"""Package the source code."""
146145
_generate_documentation(source, only_rst_man=True)
147-
if getenv("CI", "false") == "true":
148-
process = Popen(("./.venv/bin/python", "-m", "build"), shell=False) # nosec
149-
else:
150-
process = Popen(("pdm", "build"), shell=False) # nosec
146+
process = Popen(("uv", "build"), shell=False) # nosec
151147
process.communicate()
152148
return process.returncode
153149

0 commit comments

Comments
 (0)