Skip to content

Commit 752f8a5

Browse files
authored
meta: migrate to uv (#45)
* chore: migrate to uv * chore: make examples work with uv * ci: update ci to work with uv * chore: update tasks * docs: hopefully support readthedocs * docs: fix readthedocs maybe * fix(docs): try uv sync * fix(docs): prefer active env * fix(ci): provide shell * docs: update readme secretly feature creep, I just wanted to see if caching works * fix(ci): nobody saw that * refactor(ci): use uv pip install to install self
1 parent 1e45070 commit 752f8a5

File tree

14 files changed

+1931
-2415
lines changed

14 files changed

+1931
-2415
lines changed

Diff for: .env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The bot token with which to run example files.
22
# This is used as a convenient way of testing examples through
3-
# > poetry run example <example name>
3+
# > uv run task example <example name>
44

55
EXAMPLE_TOKEN = ...

Diff for: .github/actions/bootstrap/action.yml

+17-23
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,39 @@ inputs:
66
required: true
77
type: string
88

9-
outputs:
10-
python-version:
11-
description: Version of the installed Python interpreter.
12-
value: ${{ steps.setup-python.outputs.python-version }}
13-
149
runs:
1510
using: composite
1611

1712
steps:
18-
- name: Set up python
19-
id: setup-python
20-
uses: actions/setup-python@v5
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v5
2115
with:
16+
# We handle caching ourselves so we can cache the entire venv.
17+
enable-cache: false
2218
python-version: ${{ inputs.python-version }}
2319

24-
- name: Install poetry
25-
uses: snok/install-poetry@v1
26-
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
20+
- name: Configure uv
21+
run: |
22+
echo "UV_FROZEN=true" >> "$GITHUB_ENV"
23+
echo "UV_NO_SYNC=true" >> "$GITHUB_ENV"
24+
shell: bash
2925

3026
- name: Load cached venv
31-
id: cache-poetry-dependencies
27+
# Try to get entire venv from cache.
28+
id: cache-uv-dependencies
3229
uses: actions/cache@v3
3330
with:
3431
path: .venv
35-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
32+
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('**/uv.lock') }}
3633

3734
- name: Install dependencies
38-
if: steps.cache-poetry-dependencies.outputs.cache-hit != 'true'
35+
# If cache is *not* hit, install all dependencies except docs group and disnake-compass.
36+
if: steps.cache-uv-dependencies.outputs.cache-hit != 'true'
3937
run: |
40-
poetry env use ${{ steps.setup-python.outputs.python-version }}
41-
poetry install --no-interaction --no-root --without docs
38+
uv sync --all-groups --no-group docs --no-install-project
4239
shell: bash
4340

4441
- name: Install disnake-compass
45-
run: poetry install --no-interaction --only-root
46-
shell: bash
47-
48-
- name: Activate venv
49-
run: source .venv/bin/activate
42+
# Always install disnake-compass again to make sure the latest changes are reflected.
43+
run: uv pip install -e . --no-deps
5044
shell: bash

Diff for: .github/workflows/changelog.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
# NOTE: The pull request' base branch needs to be fetched so towncrier
3737
# is able to compare the current branch with the base branch.
3838
run: |
39-
if ! poetry run towncrier check --compare-with origin/${BASE_BRANCH}; then
39+
if ! uv run towncrier check --compare-with origin/${BASE_BRANCH}; then
4040
echo "::error::Please see https://github.com/DisnakeCommunity/disnake-compass/blob/master/changelog/README.md for details on how to create a changelog entry." >&2
4141
exit 1
4242
fi

Diff for: .github/workflows/create-release-pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ jobs:
4949

5050
- name: Update version
5151
run: |
52-
poetry run python scripts/versiontool.py --set "$VERSION_INPUT"
52+
uv run python scripts/versiontool.py --set "$VERSION_INPUT"
5353
git commit -a -m "chore: update version to $VERSION_INPUT"
5454
5555
- name: Build changelog
5656
run: |
57-
poetry run towncrier build --yes --version "$VERSION_INPUT"
57+
uv run towncrier build --yes --version "$VERSION_INPUT"
5858
git commit -a -m "docs: build changelog"
5959
6060
- name: Create pull request

Diff for: .github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626

2727
- name: Build package
2828
run: |
29-
poetry build
29+
uv build
3030
ls -la dist/
3131
3232
- name: Twine check
33-
run: poetry run twine check --strict dist/*
33+
run: uv run twine check --strict dist/*
3434

3535
- name: Show metadata
3636
run: |
@@ -191,7 +191,7 @@ jobs:
191191
- name: Update version to dev
192192
id: update-version
193193
run: |
194-
NEW_VERSION="$(poetry run python scripts/versiontool.py --set dev)"
194+
NEW_VERSION="$(uv run python scripts/versiontool.py --set dev)"
195195
git commit -a -m "chore: update version to v$NEW_VERSION"
196196
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
197197

Diff for: .github/workflows/validate.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: ${{ matrix.python-version }}
2323

2424
- name: Run pyright
25-
run: poetry run pyright .
25+
run: uv run pyright .
2626

2727
ruff-lint:
2828
runs-on: ubuntu-latest
@@ -37,7 +37,7 @@ jobs:
3737
python-version: '3.10'
3838

3939
- name: Run ruff linter
40-
run: poetry run ruff check --fix --exit-non-zero-on-fix
40+
run: uv run ruff check --fix --exit-non-zero-on-fix
4141

4242
ruff-format:
4343
runs-on: ubuntu-latest
@@ -52,4 +52,4 @@ jobs:
5252
python-version: '3.10'
5353

5454
- name: Run ruff formatter
55-
run: poetry run ruff format --check
55+
run: uv run ruff format --check

Diff for: .readthedocs.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ build:
55
tools:
66
python: "3.10"
77

8-
jobs:
9-
post_create_environment:
10-
- pip install poetry
11-
12-
post_install:
13-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
8+
# adapted from uv recipe at https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-uv
9+
# and comment at https://github.com/readthedocs/readthedocs.org/issues/11289#issuecomment-2103832834
10+
commands:
11+
- asdf plugin add uv
12+
- asdf install uv latest
13+
- asdf global uv latest
14+
- uv venv $READTHEDOCS_VIRTUALENV_PATH
15+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv sync --active --group docs
16+
- python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html
1417

1518
sphinx:
1619
configuration: docs/source/conf.py

Diff for: README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ Requires disnake version 2.10.0 or above and python 3.10.0 or above.
1010
Key Features
1111
------------
1212
- Smoothly integrates with disnake,
13-
- Uses an intuitive dataclass-like syntax to create innately persistent components,
14-
- `custom_id` matching, conversion, and creation are automated for you.
13+
- Intuitive dataclass-like syntax to declare component classes,
14+
- Fully stateless and persistent by permanently storing state inside custom ids,
15+
- Custom id matching, parsing, conversion and creation are all managed for you,
16+
- Highly customisable!
1517

1618
Installing
1719
----------

Diff for: changelog/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If you are not sure what issue type to use, don't hesitate to ask in your PR.
3434
``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
3535
other than ``features`` it is usually better to stick to a single paragraph to keep it concise.
3636

37-
You can also run ``poetry run task docs`` to build the documentation
37+
You can also run ``uv run task docs`` to build the documentation
3838
with the draft changelog (http://127.0.0.1:8009/whats_new.html) if you want to get a preview of how your change will look in the final release notes.
3939

4040
---

Diff for: docs/source/examples/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ The examples aim to show you how some of the features of this extension can be u
1111
These examples are also available on our :github-blob:`GitHub repository <>` without documentation, and are perfectly runnable as-is.
1212
The easiest way of running the examples is:
1313

14-
1. Clone the repository,
15-
2. Run ``poetry install`` to install dependencies,
14+
1. Ensure `uv <https://docs.astral.sh/uv/>`_ is installed,
15+
2. Clone the repository,
1616
3. Copy ``.env.example`` and name it ``.env``,
1717
4. Enter your bot token in the new ``.env`` file,
18-
5. Run ``poetry run example <name>``.
18+
5. Run ``uv run task example <name>``.
1919

2020
If you think an example is unclear or an example for a feature is missing, feel free to open a :github:`pull request <pulls>` or :github:`issue <issues>`!
2121

0 commit comments

Comments
 (0)