Skip to content

Commit 56ff0b7

Browse files
committed
Migrate to using uv + hatchling
1 parent d3b1acb commit 56ff0b7

23 files changed

+3291
-126
lines changed

.github/dependabot.yml

-23
This file was deleted.

.github/renovate.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["config:recommended"],
4-
"dependencyDashboard": false
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"dependencyDashboard": false,
7+
"lockFileMaintenance": {
8+
"enabled": true
9+
},
10+
"prHourlyLimit": 5
511
}

.github/workflows/ci.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,24 @@ jobs:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929

30-
- name: Setup python
31-
uses: actions/setup-python@v5
30+
- name: Install the latest version of uv
31+
uses: astral-sh/setup-uv@v5
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434

3535
- name: Test Installation
3636
shell: bash
3737
run: |
38-
pip install -r dev-requirements/build.txt
39-
40-
pip install .
41-
pip uninstall -y hikari
38+
uv pip install .
39+
uv pip uninstall -y hikari
4240
43-
pip install .[speedups]
44-
pip uninstall -y hikari
41+
uv pip install .[speedups]
42+
uv pip uninstall -y hikari
4543
4644
- name: Run tests
4745
shell: bash
4846
run: |
49-
pip install -r dev-requirements.txt
47+
uv pip install nox
5048
5149
nox -s pytest
5250
nox -s pytest-all-features -- --cov-append
@@ -118,15 +116,18 @@ jobs:
118116
- name: Checkout repository
119117
uses: actions/checkout@v4
120118

121-
- name: Setup python
122-
uses: actions/setup-python@v5
119+
- name: Setup uv
120+
uses: astral-sh/setup-uv@v5
123121
with:
124122
python-version: 3.9
125123

124+
- name: Install nox
125+
run: |
126+
uv pip install nox
127+
126128
- name: Check stubs
127129
if: always()
128130
run: |
129-
pip install -r dev-requirements.txt
130131
nox -s generate-stubs
131132
if [ "$(git status --short)" ]; then
132133
echo "Stubs were not updated accordingly to the changes. Please run 'nox -s generate-stubs' and commit the changes to fix this."

.github/workflows/fragments-check.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ jobs:
1919
# needs a non-shallow clone.
2020
fetch-depth: 0
2121

22-
- name: Setup python
23-
uses: actions/setup-python@v5
22+
- name: Setup uv
23+
uses: astral-sh/setup-uv@v5
2424
with:
2525
python-version: 3.9
2626

2727
- name: Check if changelog fragment was added
2828
run: |
29-
pip install -r dev-requirements/towncrier.txt
29+
# FIXME: Temporary - https://github.com/astral-sh/uv/issues/8590
30+
uv export --only-group=towncrier | uv pip install --requirements=-
3031
3132
if ! towncrier check --compare-with origin/${{ github.base_ref }}; then
3233
exit 1

.github/workflows/prepare-release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'The version to prepare the release for'
7+
description: "The version to prepare the release for"
88
required: true
99

1010
jobs:
@@ -31,8 +31,8 @@ jobs:
3131
git config --global user.name "hikari-bot"
3232
git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com"
3333
34-
- name: Setup python
35-
uses: actions/setup-python@v5
34+
- name: Setup uv
35+
uses: astral-sh/setup-uv@v5
3636
with:
3737
python-version: 3.9
3838

.github/workflows/release.yml

+4-17
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,15 @@ jobs:
2626
git config --global user.name "hikari-bot"
2727
git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com"
2828
29-
- name: Setup python
30-
uses: actions/setup-python@v5
29+
- name: Setup uv
30+
uses: astral-sh/setup-uv@v5
3131
with:
3232
python-version: 3.9
3333

34-
- name: Temporarily disable "include administrators" branch protection
35-
uses: benjefferies/branch-protection-bot@v1.1.2
36-
with:
37-
access_token: ${{ steps.generate_token.outputs.token }}
38-
enforce_admins: false
39-
4034
- name: Release
4135
env:
4236
VERSION: ${{ github.event.release.tag_name }}
4337
DEPLOY_WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
44-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
45-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
38+
UV_PUBLISH_USERNAME: ${{ secrets.TWINE_USERNAME }}
39+
UV_PUBLISH_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
4640
run: bash scripts/ci/release.sh
47-
48-
- name: Re-enable "include administrators" branch protection
49-
uses: benjefferies/branch-protection-bot@v1.1.2
50-
if: always()
51-
with:
52-
access_token: ${{ steps.generate_token.outputs.token }}
53-
enforce_admins: true

dev-requirements.txt

-1
This file was deleted.

pipelines/audit.nox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@nox.session()
3030
def audit(session: nox.Session) -> None:
3131
"""Perform dependency scanning."""
32-
session.install(*nox.dev_requirements("audit"))
32+
session.install(*nox.dev_groups("audit"))
3333
session.run(
3434
"pip-audit",
3535
"-r",

pipelines/codespell.nox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
@nox.session()
3131
def codespell(session: nox.Session) -> None:
3232
"""Run codespell to check for spelling mistakes."""
33-
session.install(*nox.dev_requirements("codespell"))
33+
session.install(*nox.dev_groups("codespell"))
3434
session.run(
3535
"codespell",
3636
"--builtin",

pipelines/flake8.nox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def flake8_html(session: nox.Session) -> None:
4040

4141

4242
def _flake8(session: nox.Session, extra_args: typing.Sequence[str] = ()) -> None:
43-
session.install("-r", "requirements.txt", *nox.dev_requirements("flake8"))
43+
session.install(".", *nox.dev_groups("flake8"))
4444
session.run(
4545
"flake8",
4646
"--statistics",

pipelines/format.nox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@nox.session()
3939
def reformat_code(session: nox.Session) -> None:
4040
"""Remove trailing whitespace in source and then run ruff code formatter."""
41-
session.install(*nox.dev_requirements("ruff"))
41+
session.install(*nox.dev_groups("ruff"))
4242

4343
remove_trailing_whitespaces(session)
4444

@@ -52,7 +52,7 @@ def reformat_code(session: nox.Session) -> None:
5252
@nox.session()
5353
def check_reformat_code(session: nox.Session) -> None:
5454
"""TEMPORARY: Check if code is properly formatted."""
55-
session.install(*nox.dev_requirements("ruff"))
55+
session.install(*nox.dev_groups("ruff"))
5656

5757
# At the time of writing, sorting imports is not done when running formatting
5858
# and needs to be done with ruff check

pipelines/mkdocs.nox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def mkdocs(session: nox.Session):
4242
"""Generate docs using mkdocs."""
4343
_setup_environ(session)
4444

45-
session.install("-e", ".", *nox.dev_requirements("mkdocs"))
45+
session.install(".", *nox.dev_groups("mkdocs"))
4646

4747
session.run("mkdocs", "build", "-d", config.DOCUMENTATION_OUTPUT_PATH)
4848

@@ -52,7 +52,7 @@ def mkdocs_serve(session: nox.Session):
5252
"""Start an HTTP server that serves the generated docs in real time."""
5353
_setup_environ(session)
5454

55-
session.install("-e", ".", *nox.dev_requirements("mkdocs"))
55+
session.install(".", *nox.dev_groups("mkdocs"))
5656

5757
if "--no-reload" in session.posargs:
5858
session.run("mkdocs", "serve", "--no-livereload")

pipelines/mypy.nox.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,7 @@
3636
@nox.session()
3737
def mypy(session: nox.Session) -> None:
3838
"""Perform static type analysis on Python source code using mypy."""
39-
session.install(
40-
"-r",
41-
"requirements.txt",
42-
"-r",
43-
"speedup-requirements.txt",
44-
"-r",
45-
"server-requirements.txt",
46-
*nox.dev_requirements("mypy", "ruff"),
47-
)
39+
session.install(".[speedups, server]", *nox.dev_groups("mypy", "ruff"))
4840

4941
_generate_stubs(session)
5042

@@ -55,7 +47,7 @@ def mypy(session: nox.Session) -> None:
5547
@nox.session()
5648
def generate_stubs(session: nox.Session) -> None:
5749
"""Generate the stubs for the package."""
58-
session.install(*nox.dev_requirements("mypy", "ruff"))
50+
session.install(*nox.dev_groups("mypy", "ruff"))
5951
_generate_stubs(session)
6052

6153

pipelines/nox.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323

2424
from __future__ import annotations
2525

26-
import os as _os
2726
import typing as _typing
2827

2928
from nox import options as _options
3029
from nox import session as _session
3130
from nox.sessions import Session
3231

33-
from pipelines import config as _pipelines_config
34-
3532
# Default sessions should be defined here
3633
_options.sessions = ["reformat-code", "codespell", "pytest", "flake8", "slotscheck", "mypy", "verify-types"]
3734
_options.default_venv_backend = "uv|venv"
@@ -48,10 +45,10 @@ def decorator(func: _NoxCallbackSig) -> _NoxCallbackSig:
4845
return decorator
4946

5047

51-
def dev_requirements(*dependencies: str) -> _typing.Sequence[str]:
48+
def dev_groups(*groups: str) -> _typing.Sequence[str]:
5249
args = []
5350

54-
for dep in dependencies:
55-
args.extend(("-r", _os.path.join(_pipelines_config.DEV_REQUIREMENTS_DIRECTORY, f"{dep}.txt")))
51+
for group in groups:
52+
args.extend(("--group", group))
5653

5754
return args

pipelines/pyright.nox.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,12 @@ def pyright(session: nox.Session) -> None:
3535
as hikari does not have 100% compatibility with pyright just yet. This
3636
exists to make it easier to test and eventually reach that 100% compatibility.
3737
"""
38-
session.install(
39-
"-r",
40-
"requirements.txt",
41-
"-r",
42-
"speedup-requirements.txt",
43-
"-r",
44-
"server-requirements.txt",
45-
*nox.dev_requirements("pyright"),
46-
)
38+
session.install(".[speedups, server]", *nox.dev_groups("pyright"))
4739
session.run("pyright")
4840

4941

5042
@nox.session()
5143
def verify_types(session: nox.Session) -> None:
5244
"""Verify the "type completeness" of types exported by the library using Pyright."""
53-
session.install(".", *nox.dev_requirements("pyright"))
45+
session.install(".", *nox.dev_groups("pyright"))
5446
session.run("pyright", "--verifytypes", config.MAIN_PACKAGE, "--ignoreexternal")

pipelines/pytest.nox.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ def pytest_all_features(session: nox.Session) -> None:
5959
Coverage can be disabled with the `--skip-coverage` flag.
6060
"""
6161

62-
_pytest(
63-
session,
64-
extra_install=("-r", "server-requirements.txt", "-r", "speedup-requirements.txt"),
65-
python_flags=("-OO",),
66-
)
62+
_pytest(session, extra_install=(".[speedups, server]",), python_flags=("-OO",))
6763

6864

6965
def _pytest(
7066
session: nox.Session, *, extra_install: typing.Sequence[str] = (), python_flags: typing.Sequence[str] = ()
7167
) -> None:
72-
session.install("-r", "requirements.txt", *extra_install, *nox.dev_requirements("pytest"))
68+
session.install(".", *extra_install, *nox.dev_groups("pytest"))
7369

7470
if "--skip-coverage" in session.posargs:
7571
session.posargs.remove("--skip-coverage")

pipelines/slotscheck.nox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
@nox.session()
3131
def slotscheck(session: nox.Session) -> None:
3232
"""Check for common slotting mistakes."""
33-
session.install(".", *nox.dev_requirements("slotscheck"))
33+
session.install(".", *nox.dev_groups("slotscheck"))
3434
session.run("slotscheck", "-m", config.MAIN_PACKAGE)

pipelines/twemoji.nox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
@nox.session()
2828
def twemoji_test(session: nox.Session):
2929
"""Brute-force test all possible Twemoji mappings for Discord unicode emojis."""
30-
session.install("-e", ".")
30+
session.install(".")
3131
session.run("python", "scripts/ci/test_twemoji_mapping.py", session.create_tmp())

pyproject.toml

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
2121
[build-system]
22-
requires = ["wheel", "setuptools", "setuptools-scm"]
23-
build-backend = "setuptools.build_meta"
22+
requires = ["hatchling>=1.14"]
23+
build-backend = "hatchling.build"
2424

25-
[tool.setuptools.packages.find]
26-
where = ["."]
27-
include = ["hikari*"]
28-
29-
[tool.setuptools.dynamic]
30-
version = { attr = "hikari._about.__version__" }
25+
[tool.hatch.version]
26+
path = "hikari/_about.py"
27+
pattern = '__version__: typing\.Final\[str\] = \"(?P<version>[^\"]+)\"'
3128

3229
[project]
3330
dynamic = ["version"]
@@ -119,7 +116,7 @@ mkdocs = [
119116
# Minify
120117
"mkdocs-minify-plugin==0.8.0",
121118
# Towncrier draft changelogs
122-
"mkdocs-towncrier==0.1.3",
119+
"mkdocs-towncrier==0.1.4",
123120
# Image viewer ext
124121
# "mkdocs-glightbox==0.3.7",
125122
]
@@ -139,6 +136,9 @@ ruff = ["ruff==0.9.9"]
139136
slotscheck = ["slotscheck==0.19.1"]
140137
towncrier = ["towncrier==24.8.0"]
141138

139+
[tool.uv]
140+
required-version = "~=0.5"
141+
142142
[tool.ruff]
143143
line-length = 120
144144
target-version = "py39"

scripts/ci/prepare-release.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ sed "/^__docs__.*/, \${s||__docs__: typing.Final[str] = \"https://docs.hikari-py
3535
echo "===== UPDATING CHANGELOG ====="
3636
echo "-- Installing dependencies --"
3737
# Installing our own package is necessary to have towncrier detect the version
38-
pip install -r dev-requirements/towncrier.txt -e .
38+
# FIXME: Change to allow also just using pip
39+
uv pip install --group towncrier .
3940

4041
echo "-- Running towncrier --"
4142
towncrier --yes

0 commit comments

Comments
 (0)