Skip to content

Commit

Permalink
Compile development dependencies with uv compile
Browse files Browse the repository at this point in the history
  • Loading branch information
davfsa committed Aug 4, 2024
1 parent 5592b52 commit defcd2b
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Language aware diff headers
*.py diff=python

# Autogenerated files
dev-requirements/*.txt linguist-generated=true
25 changes: 25 additions & 0 deletions .github/workflows/check-dependency-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dependency Locks Check

on:
pull_request:
paths:
- dev-requirements/*

jobs:
check-locks:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Check dependency locks
run: |
pip install -r dev-requirements.txt
nox -s check-dependency-locks
1 change: 1 addition & 0 deletions dev-requirements/audit.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip-audit==2.7.3
2 changes: 2 additions & 0 deletions dev-requirements/build.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setuptools>=65.2.0
wheel==0.43.0
1 change: 1 addition & 0 deletions dev-requirements/codespell.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codespell==2.3.0
1 change: 1 addition & 0 deletions dev-requirements/coverage.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage[toml]==7.6.0
24 changes: 24 additions & 0 deletions dev-requirements/flake8.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
flake8==7.1.0

# Plugins
# Ref: https://github.com/DmytroLitvinov/awesome-flake8-extensions

flake8-bandit~=4.1.1 # runs bandit
flake8-black==0.3.6 # runs black
flake8-builtins==2.5.0 # builtin shadowing checks
flake8-coding==1.3.2 # coding magic-comment detection
flake8-comprehensions==3.15.0 # comprehension checks
flake8-docstrings==1.7.0 # pydocstyle support
flake8-executable==2.1.3 # shebangs
flake8-fixme==1.1.1 # "fix me" counter
flake8-functions==0.0.8 # function linting
flake8-html==0.4.3 # html output
flake8-isort==6.1.1 # runs isort
flake8-mutable==1.2.0 # mutable default argument detection
flake8-pep3101==2.1.0 # new-style format strings only
flake8-print==5.0.0 # complain about print statements in code
flake8-printf-formatting==1.1.2 # forbey printf-style python2 string formatting
flake8-pytest-style==2.0.0 # pytest checks
flake8-raise==0.0.5 # exception raising linting
flake8-use-fstring==1.4 # format string checking
flake8-noqa==1.4.0 # validate noqa commands
2 changes: 2 additions & 0 deletions dev-requirements/formatting.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black==24.4.2
isort==5.13.2
21 changes: 21 additions & 0 deletions dev-requirements/mkdocs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
mkdocs==1.6.0

# Mkdocs Material
mkdocs-material[imaging]==9.5.31

# Docstring parsing for API reference
mkdocstrings[python]==0.25.2
griffe-inherited-docstrings==1.0.0

# Generate API reference pages dynamically
mkdocs-gen-files==0.5.0
mkdocs-literate-nav==0.6.1

# Minify
mkdocs-minify-plugin==0.8.0

# Formatting signatures
black==24.4.2

# Image viewer ext
# mkdocs-glightbox==0.3.7
1 change: 1 addition & 0 deletions dev-requirements/mypy.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mypy==1.10.1
1 change: 1 addition & 0 deletions dev-requirements/pyright.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyright==1.1.374
11 changes: 11 additions & 0 deletions dev-requirements/pytest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# mock in the stdlib changes between versions of Python, so are not consistent in behaviour like the backport is
mock==5.1.0

pytest==8.3.2
pytest-asyncio==0.23.8
pytest-cov==5.0.0
pytest-randomly==3.15.0

async-timeout==4.0.3 # Used for timeouts in some test cases.

-r coverage.in # Consistent coverage version
3 changes: 3 additions & 0 deletions dev-requirements/release.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
twine==5.1.1

-r build.in
1 change: 1 addition & 0 deletions dev-requirements/slotscheck.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
slotscheck==0.19.0
1 change: 1 addition & 0 deletions dev-requirements/towncrier.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
towncrier==24.7.1
71 changes: 71 additions & 0 deletions pipelines/lockfiles.nox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Nekokatt
# Copyright (c) 2021-present davfsa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Lock file pipelines."""
import pathlib

from pipelines import config
from pipelines import nox


def _generate_lock(session: nox.Session, requirements_path: pathlib.Path) -> str:
return session.run(
"uv",
"pip",
"compile",
requirements_path,
"-q",
"--universal",
"--generate-hashes",
"--python-version",
"3.8.1", # This will be the minimum version allowed for development dependencies
silent=True,
)


@nox.session(venv_backend="none")
def lock_dependencies(session: nox.Session) -> None:
"""Generate development dependencies locks."""

for req_in in pathlib.Path(config.DEV_REQUIREMENTS_DIRECTORY).glob("*.in"):
lock = _generate_lock(session, req_in)

output_path = req_in.with_suffix(".txt")
output_path.write_text(lock)


@nox.session(venv_backend="none")
def check_dependency_locks(session: nox.Session) -> None:
"""Check dependencies locks."""
failure = False

for req_in in pathlib.Path(config.DEV_REQUIREMENTS_DIRECTORY).glob("*.in"):
expected = _generate_lock(session, req_in)

output_path = req_in.with_suffix(".txt")
current = output_path.read_text()

if expected != current:
failure = True
session.warn(f"{output_path} is not up to date!")

if failure:
session.error("Found outdated locks, try running `nox -s lock-dependencies` to fix them")
12 changes: 1 addition & 11 deletions pipelines/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@

from pipelines import config as _pipelines_config

try:
import uv

del uv

venv_backend = "uv"
except ModuleNotFoundError:
venv_backend = "venv"


# Default sessions should be defined here
_options.sessions = ["reformat-code", "codespell", "pytest", "flake8", "slotscheck", "mypy", "verify-types"]
_options.default_venv_backend = venv_backend
_options.default_venv_backend = "uv"

_NoxCallbackSig = _typing.Callable[[Session], None]

Expand Down

0 comments on commit defcd2b

Please sign in to comment.