Skip to content

Commit e32e574

Browse files
authored
ci: Migrate from pdm to uv (#331)
* Add uv.lock to .gitignore and remove .pdm-python from it * Change pdm to uv in CONTRIBUTING.md * Change pdm to uv in tests.yml, build-deploy-docs.yml and release.yml * Change build-system to setuptools * Change license classifier to a license field in pyproject.toml Theoretically, this should only affect contributors and CI.
1 parent 0f815b5 commit e32e574

File tree

6 files changed

+63
-42
lines changed

6 files changed

+63
-42
lines changed

.github/workflows/build-deploy-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
1919

20-
- name: Setup PDM
21-
uses: pdm-project/setup-pdm@v4
20+
- name: Set up uv
21+
uses: astral-sh/setup-uv@v5
2222
with:
2323
python-version: '3.13'
2424

2525
- name: Install dependencies (default with full options & doc)
26-
run: pdm install --group full --group doc --frozen-lockfile
26+
run: uv pip install '.[full]' --group doc
2727

2828
- name: Determine deployment folder
2929
id: deploy_folder
@@ -41,7 +41,7 @@ jobs:
4141
4242
- name: Build Documentation
4343
working-directory: docs
44-
run: pdm run make dirhtml
44+
run: uv run make dirhtml
4545
env:
4646
TORCHJD_VERSION: ${{ steps.deploy_folder.outputs.TORCHJD_VERSION }}
4747

.github/workflows/release.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Release
22

3-
# Adapted from https://pdm-project.org/latest/usage/publish/
43
on:
54
release:
65
types: [published]
@@ -14,7 +13,16 @@ jobs:
1413
# IMPORTANT: this permission is mandatory for trusted publishing
1514
id-token: write
1615
steps:
17-
- uses: actions/checkout@v4
18-
- uses: pdm-project/setup-pdm@v4
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up uv
20+
uses: astral-sh/setup-uv@v5
21+
with:
22+
python-version: '3.13'
23+
24+
- name: Build
25+
run: uv build
26+
1927
- name: Publish package distributions to PyPI
20-
run: pdm publish
28+
run: uv publish -v

.github/workflows/tests.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- name: Set up PDM
22-
uses: pdm-project/setup-pdm@v4
21+
- name: Set up uv
22+
uses: astral-sh/setup-uv@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install default (with full options) and test dependencies
26-
run: pdm install --group full --group test --frozen-lockfile
26+
run: uv pip install '.[full]' --group test
2727
- name: Run unit and doc tests with coverage report
28-
run: pdm run pytest tests/unit tests/doc --cov=src --cov-report=xml
28+
run: uv run pytest tests/unit tests/doc --cov=src --cov-report=xml
2929
- name: Upload results to Codecov
3030
uses: codecov/codecov-action@v4
3131
with:
@@ -36,15 +36,15 @@ jobs:
3636
runs-on: ubuntu-latest
3737
steps:
3838
- uses: actions/checkout@v4
39-
- name: Set up PDM
40-
uses: pdm-project/setup-pdm@v4
39+
- name: Set up uv
40+
uses: astral-sh/setup-uv@v5
4141
with:
4242
python-version: '3.13'
4343
- name: Install default (without any option) and test dependencies
44-
run: pdm install --group test --frozen-lockfile
44+
run: uv pip install . --group test
4545
- name: Run unit and doc tests with coverage report
4646
run: |
47-
pdm run pytest tests/unit tests/doc \
47+
uv run pytest tests/unit tests/doc \
4848
--ignore tests/unit/aggregation/test_cagrad.py \
4949
--ignore tests/unit/aggregation/test_nash_mtl.py \
5050
--ignore tests/doc/test_aggregation.py \
@@ -61,14 +61,14 @@ jobs:
6161
- name: Checkout repository
6262
uses: actions/checkout@v4
6363

64-
- name: Setup PDM
65-
uses: pdm-project/setup-pdm@v4
64+
- name: Set up uv
65+
uses: astral-sh/setup-uv@v5
6666
with:
6767
python-version: '3.13'
6868

6969
- name: Install dependencies (default with full options & doc)
70-
run: pdm install --group full --group doc --frozen-lockfile
70+
run: uv pip install '.[full]' --group doc
7171

7272
- name: Build Documentation
7373
working-directory: docs
74-
run: pdm run make dirhtml
74+
run: uv run make dirhtml

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# pdm
2-
.pdm-python
1+
# uv
2+
uv.lock
33

44
# PyCharm
55
.idea/

CONTRIBUTING.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,71 @@ with maintainers before implementing major changes.
55

66
## Installation
77

8-
1) Pre-requisites: To work with TorchJD, you need Python to be installed. In the following, we
9-
suggest to use Python 3.13.1, but you can work with any python version supported by `torchjd`. We
10-
use [pyenv](https://github.com/pyenv/pyenv) to install Python and
11-
[pdm](https://pdm-project.org/en/latest/) to manage dependencies. While the desired Python
12-
version can also be installed without pyenv, the installation of `torchjd` for development
13-
purposes requires `pdm`. To install it, follow their
14-
[installation steps](https://pdm-project.org/en/latest/#installation).
8+
To work with TorchJD, we suggest you to use [uv](https://docs.astral.sh/uv/). While this is not
9+
mandatory, we only provide installation steps with this tool. You can install it by following their
10+
[installation documentation](https://docs.astral.sh/uv/getting-started/installation/).
11+
12+
1) Pre-requisites: Use `uv` to install a Python version compatible with TorchJD and to pin it to the
13+
`torchjd` folder. From the root of the `torchjd` repo, run:
14+
```bash
15+
uv python install 3.13.3
16+
uv python pin 3.13.3
17+
```
1518

1619
2) Create a virtual environment and install the project in it. From the root of `torchjd`, run:
1720
```bash
18-
pdm venv create 3.13.1 # Requires Python 3.13.1 to be installed
19-
pdm use -i .venv/bin/python
20-
pdm install --group full --frozen-lockfile
21-
pdm run pre-commit install
21+
uv venv
22+
CC=gcc uv pip install '.[full]' --group check --group doc --group test --group plot
23+
uv run pre-commit install
2224
```
2325

26+
> [!TIP]
27+
> If you're running into issues when `uv` tries to compile `ecos`, make sure that `gcc` is
28+
> installed. Alternatively, you can try to install `clang` or try to use some older Python version
29+
> (3.12) for which `ecos` has provided compiled packages (the list is accessible
30+
> [here](https://pypi.org/project/ecos/#files)).
31+
2432
> [!TIP]
2533
> The Python version that you should specify in your IDE is `<path-to-torchjd>/.venv/bin/python`.
2634
35+
> [!TIP]
36+
> In the following commands, you can get rid of the `uv run` prefix if you activate the `venv`
37+
> created by `uv`, using `source .venv/bin/activate` from the root of `torchjd`. This will, however,
38+
> only work in the current terminal until it is closed.
39+
2740
## Running tests
2841
- To verify that your installation was successful, and that all unit tests pass, run:
2942
```bash
30-
pdm run pytest tests/unit
43+
uv run pytest tests/unit
3144
```
3245

3346
- If you have access to a cuda-enabled GPU, you should also check that the unit tests pass on it:
3447
```bash
35-
CUBLAS_WORKSPACE_CONFIG=:4096:8 PYTEST_TORCH_DEVICE=cuda:0 pdm run pytest tests/unit
48+
CUBLAS_WORKSPACE_CONFIG=:4096:8 PYTEST_TORCH_DEVICE=cuda:0 uv run pytest tests/unit
3649
```
3750

3851
- To check that the usage examples from docstrings and `.rst` files are correct, we test their
3952
behavior in `tests/doc`. To run these tests, do:
4053
```bash
41-
pdm run pytest tests/doc
54+
uv run pytest tests/doc
4255
```
4356

4457
- To compute the code coverage locally, you should run the unit tests and the doc tests together,
4558
with the `--cov` flag:
4659
```bash
47-
pdm run pytest tests/unit tests/doc --cov=src
60+
uv run pytest tests/unit tests/doc --cov=src
4861
```
4962

5063
## Building the documentation locally
5164
- From the `docs` folder, run:
5265
```bash
53-
pdm run make html
66+
uv run make html
5467
```
5568
- You can then open `docs/build/html/index.html` with a web browser.
5669
- Sometimes, you need to manually delete the built documentation before generating it. To do
5770
this, from the `docs` folder, run:
5871
```bash
59-
pdm run make clean
72+
uv run make clean
6073
```
6174

6275
## Development guidelines

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["pdm-backend"]
3-
build-backend = "pdm.backend"
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "torchjd"
@@ -22,7 +22,6 @@ classifiers = [
2222
"Development Status :: 4 - Beta",
2323
"Intended Audience :: Developers",
2424
"Intended Audience :: Science/Research",
25-
"License :: OSI Approved :: MIT License",
2625
"Operating System :: OS Independent",
2726
"Programming Language :: Python",
2827
"Programming Language :: Python :: 3",
@@ -33,6 +32,7 @@ classifiers = [
3332
"Topic :: Scientific/Engineering",
3433
"Topic :: Scientific/Engineering :: Artificial Intelligence",
3534
]
35+
license = "MIT"
3636

3737
[project.urls]
3838
Homepage = "https://torchjd.org/"

0 commit comments

Comments
 (0)