Skip to content

Commit 6d3310f

Browse files
Change poetry to uv (#358)
* Change poetry to uv * Update docs * Update tox to use uv * Update publish workflow * Tidy and remove unnecessary dependencies * Update uv version
1 parent e2b79f6 commit 6d3310f

File tree

9 files changed

+264
-252
lines changed

9 files changed

+264
-252
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,30 @@ jobs:
1212
python-version: ['3.9','3.10','3.11','3.12']
1313

1414
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
22-
- name: Install poetry
23-
run: pipx install poetry
24-
25-
- name: Install python dependencies
26-
run: |
27-
poetry env use ${{ matrix.python-version }}
28-
poetry install --with dev --extras all
29-
30-
- name: Run test suite
31-
env:
32-
# show timings of tests
33-
PYTEST_ADDOPTS: "--durations=0"
34-
run: poetry run pytest --run-extra-mlips --cov janus_core --cov-append .
35-
36-
- name: Report coverage to Coveralls
37-
uses: coverallsapp/github-action@v2
38-
with:
39-
parallel: true
40-
flag-name: run-${{ matrix.python-version }}
41-
file: coverage.xml
42-
base-path: janus_core
15+
- uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v4
19+
with:
20+
version: "0.5.7"
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: uv sync --all-extras
25+
26+
- name: Run test suite
27+
env:
28+
# show timings of tests
29+
PYTEST_ADDOPTS: "--durations=0"
30+
run: uv run pytest --run-extra-mlips --cov janus_core --cov-append .
31+
32+
- name: Report coverage to Coveralls
33+
uses: coverallsapp/github-action@v2
34+
with:
35+
parallel: true
36+
flag-name: run-${{ matrix.python-version }}
37+
file: coverage.xml
38+
base-path: janus_core
4339

4440
coverage:
4541
needs: tests
@@ -54,50 +50,42 @@ jobs:
5450
runs-on: ubuntu-latest
5551
timeout-minutes: 15
5652
steps:
57-
- uses: actions/checkout@v4
58-
59-
- name: Check all sources documented
60-
run: |
61-
diff -y --suppress-common-lines \
62-
<(git ls-files janus_core/** | sed '/.py$/!d; s/\/__init__.py//; s#/#.#g; s/.py$//' | sort) \
63-
<(sed -nr '/automodule/{s/.*::\s*//;p}' docs/source/apidoc/* | sort)
53+
- uses: actions/checkout@v4
6454

65-
- name: Set up Python 3.11
66-
uses: actions/setup-python@v5
67-
with:
68-
python-version: '3.11'
55+
- name: Check all sources documented
56+
run: |
57+
diff -y --suppress-common-lines \
58+
<(git ls-files janus_core/** | sed '/.py$/!d; s/\/__init__.py//; s#/#.#g; s/.py$//' | sort) \
59+
<(sed -nr '/automodule/{s/.*::\s*//;p}' docs/source/apidoc/* | sort)
6960
70-
- name: Install poetry
71-
run: pipx install poetry
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v4
63+
with:
64+
version: "0.5.7"
65+
python-version: "3.12"
7266

73-
- name: Install python dependencies
74-
run: |
75-
poetry env use 3.11
76-
poetry install --with docs
67+
- name: Install dependencies
68+
run: uv sync
7769

78-
- name: Build docs
79-
run: cd docs && poetry run make
70+
- name: Build docs
71+
run: cd docs && uv run make html
8072

8173
pre-commit:
8274
runs-on: ubuntu-latest
8375
timeout-minutes: 15
8476
steps:
85-
- uses: actions/checkout@v4
77+
- uses: actions/checkout@v4
8678

87-
- name: Set up Python 3.11
88-
uses: actions/setup-python@v5
89-
with:
90-
python-version: '3.11'
91-
92-
- name: Install poetry
93-
run: pipx install poetry
79+
- name: Install uv
80+
uses: astral-sh/setup-uv@v4
81+
with:
82+
version: "0.5.7"
83+
python-version: "3.12"
9484

95-
- name: Install python dependencies
96-
run: |
97-
poetry env use 3.11
98-
poetry install --with pre-commit,docs,dev --extras "chgnet m3gnet"
85+
- name: Install dependencies
86+
run: uv sync
9987

100-
- name: Run pre-commit
101-
run: |
102-
poetry run pre-commit install
103-
poetry run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
88+
- name: Run pre-commit
89+
run: |
90+
uv run pre-commit install
91+
uv run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )

.github/workflows/docs.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,28 @@ jobs:
2222
name: github-pages
2323
url: ${{ steps.deployment.outputs.page_url }}
2424
runs-on: ubuntu-latest
25-
container: sphinxdoc/sphinx
2625

2726
steps:
28-
- uses: actions/checkout@v4
29-
30-
- name: Install poetry
31-
run: |
32-
apt update
33-
apt upgrade -y
34-
apt install -y pipx
35-
pipx install poetry
36-
37-
- name: add deps
38-
run: |
39-
apt install -y python3-dev build-essential
40-
41-
- name: sphinx
42-
run: |
43-
export PATH="$HOME/.local/bin:$PATH"
44-
poetry install --with docs
45-
cd docs
46-
poetry run make html
47-
48-
- name: upload
49-
uses: actions/upload-pages-artifact@v3
50-
with:
51-
# Upload entire repository
52-
path: './docs/build/html/.'
53-
54-
- name: Deploy to GitHub Pages
55-
id: deployment
56-
uses: actions/deploy-pages@v4
27+
- uses: actions/checkout@v4
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v4
31+
with:
32+
version: "0.5.7"
33+
python-version: "3.12"
34+
35+
- name: Install dependencies
36+
run: uv sync
37+
38+
- name: Build docs
39+
run: cd docs && uv run make html
40+
41+
- name: upload
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
# Upload entire repository
45+
path: './docs/build/html/.'
46+
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

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

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,42 @@ jobs:
1010
publish:
1111
runs-on: ubuntu-latest
1212
if: github.repository == 'stfc/janus-core' && startsWith(github.ref, 'refs/tags/v')
13+
environment:
14+
name: release
1315

1416
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
17-
18-
- name: Set up Python 3.11
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: '3.11'
22-
23-
- name: Install poetry
24-
run: pipx install poetry
25-
26-
- name: Build project for distribution
27-
run: |
28-
poetry env use 3.11
29-
poetry build
30-
31-
- name: Check prerelease
32-
id: check-prerelease
33-
run: |
34-
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
35-
36-
- name: Get version from pyproject.toml
37-
run: |
38-
export PYTHONPATH=$(pwd)
39-
echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
40-
41-
- name: Check version matches tag
42-
if: ${{ ! contains(github.ref, env.VERSION) }}
43-
run: |
44-
echo "Git tag does not match version in pyproject.toml"
45-
exit 1
46-
47-
- name: Create Release
48-
uses: ncipollo/release-action@v1
49-
with:
50-
artifacts: "dist/*"
51-
token: ${{ secrets.GITHUB_TOKEN }}
52-
draft: false
53-
prerelease: steps.check-prerelease.outputs.prerelease == 'true'
54-
skipIfReleaseExists: true
55-
56-
- name: Publish to PyPI
57-
env:
58-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
59-
run: poetry publish
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v4
22+
with:
23+
version: "0.5.7"
24+
python-version: "3.12"
25+
26+
- name: Install dependencies
27+
run: uv sync
28+
29+
- name: Build
30+
run: uv build
31+
32+
- name: Get version from pyproject.toml
33+
run: echo "VERSION=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)" >> $GITHUB_ENV
34+
35+
- name: Check version matches tag
36+
if: ${{ ! contains(github.ref, env.VERSION) }}
37+
run: |
38+
echo "Git tag does not match version in pyproject.toml"
39+
exit 1
40+
41+
- name: Create Release
42+
uses: ncipollo/release-action@v1
43+
with:
44+
artifacts: "dist/*"
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
draft: false
47+
prerelease: steps.check-prerelease.outputs.prerelease == 'true'
48+
skipIfReleaseExists: true
49+
50+
- name: Publish to PyPI
51+
run: uv publish

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ or to install all supported MLIPs:
6060
python3 -m pip install janus-core[all]
6161
```
6262

63-
Individual `extras` are listed in [Getting Started](https://stfc.github.io/janus-core/getting_started/getting_started.html#installation), as well as in [pyproject.toml](pyproject.toml) under `[tool.poetry.extras]`.
63+
Individual `extras` are listed in [Getting Started](https://stfc.github.io/janus-core/getting_started/getting_started.html#installation), as well as in [pyproject.toml](pyproject.toml) under `[project.optional-dependencies]`.
6464

6565

6666
### Further help
@@ -282,19 +282,18 @@ This is also the case the calculations performed using the CLI, with the same in
282282

283283
## Development
284284

285-
We recommend installing poetry for dependency management when developing for `janus-core`:
285+
We recommend installing uv for dependency management when developing for `janus-core`:
286286

287-
1. Install [poetry](https://python-poetry.org/docs/#installation)
288-
2. (Optional) Create a virtual environment
289-
3. Install `janus-core` with dependencies:
287+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation)
288+
2. Install `janus-core` with dependencies in a virtual environment:
290289

291290
```shell
292291
git clone https://github.com/stfc/janus-core
293292
cd janus-core
294-
python3 -m pip install --upgrade pip
295-
poetry install --with pre-commit,dev,docs # install with useful dev dependencies
296-
pre-commit install # install pre-commit hooks
297-
pytest -v # discover and run all tests
293+
uv sync --all-extras # Create a virtual environment and install all dependencies
294+
source .venv/bin/activate
295+
pre-commit install # Install pre-commit hooks
296+
pytest -v # Discover and run all tests
298297
```
299298

300299

docs/source/developer_guide/get_started.rst

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22
Getting started
33
===============
44

5-
We recommend `installing poetry <https://python-poetry.org/docs/#installation>`_ for dependency management when developing for ``janus-core``.
5+
We recommend `installing uv <https://docs.astral.sh/uv/getting-started/installation/>`_ for dependency management when developing for ``janus-core``.
66

77
This provides a number of useful features, including:
88

9-
- Dependency management (``poetry [add,update,remove]`` etc.) and organization (groups)
10-
- Storing the versions of all installations in a ``poetry.lock`` file, for reproducible builds
11-
- Improved dependency resolution
12-
- Virtual environment management (optional)
13-
- Building and publishing tools
9+
- `Dependency management <https://docs.astral.sh/uv/concepts/projects/dependencies/>`_ (``uv [add,remove]`` etc.) and organization (`groups <https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups>`_)
10+
11+
- Storing the versions of all installations in a `uv.lock <https://docs.astral.sh/uv/concepts/projects/sync/>`_ file, for reproducible builds
12+
13+
- Improved `dependency resolution <https://docs.astral.sh/uv/concepts/resolution/>`_
14+
15+
- Virtual environment management
16+
17+
- `Building and publishing <https://docs.astral.sh/uv/guides/publish/>`_ tools
18+
19+
* Currently, an external build backend, such as `pdm <https://pypi.org/project/pdm-backend>`_, is required
20+
1421

1522
Dependencies useful for development can then be installed by running::
1623

17-
poetry install --with pre-commit,dev,docs
24+
uv sync
25+
source .venv/bin/activate
26+
1827

1928
Extras, such as optional MLIPs, can also be installed by running::
2029

21-
poetry install --with pre-commit,dev,docs --extras "alignn sevennet"
30+
uv sync --extra alignn --extra sevennet
2231

2332
or to install all supported MLIPs::
2433

25-
poetry install --with pre-commit,dev,docs --extras all
34+
uv sync --all-extras
2635

2736

2837
Running unit tests

0 commit comments

Comments
 (0)