Skip to content

meta: migrate to uv #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The bot token with which to run example files.
# This is used as a convenient way of testing examples through
# > poetry run example <example name>
# > uv run task example <example name>

EXAMPLE_TOKEN = ...
40 changes: 17 additions & 23 deletions .github/actions/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,39 @@ inputs:
required: true
type: string

outputs:
python-version:
description: Version of the installed Python interpreter.
value: ${{ steps.setup-python.outputs.python-version }}

runs:
using: composite

steps:
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# We handle caching ourselves so we can cache the entire venv.
enable-cache: false
python-version: ${{ inputs.python-version }}

- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Configure uv
run: |
echo "UV_FROZEN=true" >> "$GITHUB_ENV"
echo "UV_NO_SYNC=true" >> "$GITHUB_ENV"
shell: bash

- name: Load cached venv
id: cache-poetry-dependencies
# Try to get entire venv from cache.
id: cache-uv-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('**/uv.lock') }}

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

- name: Install disnake-compass
run: poetry install --no-interaction --only-root
shell: bash

- name: Activate venv
run: source .venv/bin/activate
# Always install disnake-compass again to make sure the latest changes are reflected.
run: uv pip install -e . --no-deps
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# NOTE: The pull request' base branch needs to be fetched so towncrier
# is able to compare the current branch with the base branch.
run: |
if ! poetry run towncrier check --compare-with origin/${BASE_BRANCH}; then
if ! uv run towncrier check --compare-with origin/${BASE_BRANCH}; then
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
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ jobs:

- name: Update version
run: |
poetry run python scripts/versiontool.py --set "$VERSION_INPUT"
uv run python scripts/versiontool.py --set "$VERSION_INPUT"
git commit -a -m "chore: update version to $VERSION_INPUT"

- name: Build changelog
run: |
poetry run towncrier build --yes --version "$VERSION_INPUT"
uv run towncrier build --yes --version "$VERSION_INPUT"
git commit -a -m "docs: build changelog"

- name: Create pull request
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:

- name: Build package
run: |
poetry build
uv build
ls -la dist/

- name: Twine check
run: poetry run twine check --strict dist/*
run: uv run twine check --strict dist/*

- name: Show metadata
run: |
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
- name: Update version to dev
id: update-version
run: |
NEW_VERSION="$(poetry run python scripts/versiontool.py --set dev)"
NEW_VERSION="$(uv run python scripts/versiontool.py --set dev)"
git commit -a -m "chore: update version to v$NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Run pyright
run: poetry run pyright .
run: uv run pyright .

ruff-lint:
runs-on: ubuntu-latest
Expand All @@ -37,7 +37,7 @@ jobs:
python-version: '3.10'

- name: Run ruff linter
run: poetry run ruff check --fix --exit-non-zero-on-fix
run: uv run ruff check --fix --exit-non-zero-on-fix

ruff-format:
runs-on: ubuntu-latest
Expand All @@ -52,4 +52,4 @@ jobs:
python-version: '3.10'

- name: Run ruff formatter
run: poetry run ruff format --check
run: uv run ruff format --check
15 changes: 9 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ build:
tools:
python: "3.10"

jobs:
post_create_environment:
- pip install poetry

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

sphinx:
configuration: docs/source/conf.py
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ Requires disnake version 2.10.0 or above and python 3.10.0 or above.
Key Features
------------
- Smoothly integrates with disnake,
- Uses an intuitive dataclass-like syntax to create innately persistent components,
- `custom_id` matching, conversion, and creation are automated for you.
- Intuitive dataclass-like syntax to declare component classes,
- Fully stateless and persistent by permanently storing state inside custom ids,
- Custom id matching, parsing, conversion and creation are all managed for you,
- Highly customisable!

Installing
----------
Expand Down
2 changes: 1 addition & 1 deletion changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you are not sure what issue type to use, don't hesitate to ask in your PR.
``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
other than ``features`` it is usually better to stick to a single paragraph to keep it concise.

You can also run ``poetry run task docs`` to build the documentation
You can also run ``uv run task docs`` to build the documentation
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.

---
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ The examples aim to show you how some of the features of this extension can be u
These examples are also available on our :github-blob:`GitHub repository <>` without documentation, and are perfectly runnable as-is.
The easiest way of running the examples is:

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

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>`!

Expand Down
Loading