Skip to content

Commit

Permalink
Begin migration to PDM.
Browse files Browse the repository at this point in the history
This will *not* require PDM in order to install or use django-registration,
but will require PDM in order to build the distributable artifacts, run CI,
and work on the package locally.
  • Loading branch information
ubernostrum committed Oct 30, 2024
1 parent 5efeaa1 commit 9a09383
Show file tree
Hide file tree
Showing 7 changed files with 1,283 additions and 63 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Harden Runner
Expand All @@ -42,6 +42,10 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: "Install dependencies"
run: |
python -VV
Expand All @@ -50,4 +54,4 @@ jobs:
python -Im pip install --upgrade nox
python -Im nox --version
- name: "Run CI suite with nox"
run: "python -Im nox --non-interactive --error-on-external-run --python ${{ matrix.python-version }}"
run: "python -Im nox --non-interactive --python ${{ matrix.python-version }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ cython_debug/
# IDEs.
.idea/
.vscode/

# PDM local file.
.pdm-python
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

44 changes: 26 additions & 18 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
nox.options.default_venv_backend = "venv"
nox.options.reuse_existing_virtualenvs = True

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})

PACKAGE_NAME = "django_registration"

NOXFILE_PATH = pathlib.Path(__file__).parents[0]
Expand Down Expand Up @@ -57,21 +59,22 @@ def clean(paths: typing.Iterable[pathlib.Path] = ARTIFACT_PATHS) -> None:
@nox.parametrize(
"python,django",
[
# Python/Django testing matrix. Tests Django 4.2, 5.0, 5.1 on Python 3.8 through
# Python/Django testing matrix. Tests Django 4.2, 5.0, 5.1 on Python 3.9 through
# 3.12, skipping unsupported combinations.
(python, django)
for python in ["3.8", "3.9", "3.10", "3.11", "3.12"]
for python in ["3.9", "3.10", "3.11", "3.12", "3.13"]
for django in ["4.2", "5.0", "5.1"]
if (python, django)
not in [("3.8", "5.0"), ("3.9", "5.0"), ("3.8", "5.1"), ("3.9", "5.1")]
not in [("3.9", "5.0"), ("3.9", "5.1"), ("3.13", "4.2"), ("3.13", "5.0")]
],
)
def tests_with_coverage(session: nox.Session, django: str) -> None:
"""
Run the package's unit tests, with coverage report.
"""
session.install(f"Django~={django}.0", ".[tests]")
session.install(f"Django~={django}.0")
session.run_always("pdm", "install", "-dG", "tests", external=True)
python_version = session.run(
f"{session.bin}/python{session.python}", "--version", silent=True
).strip()
Expand Down Expand Up @@ -115,18 +118,21 @@ def docs_build(session: nox.Session) -> None:
Build the package's documentation as HTML.
"""
session.install(".[docs]")
session.chdir("docs")
session.run_always("pdm", "install", "-dG", "docs", external=True)
build_dir = session.create_tmp()
session.run(
f"{session.bin}/python{session.python}",
"-Im",
"sphinx",
"-b",
"--builder",
"html",
"-d",
f"{session.bin}/../tmp/doctrees",
".",
f"{session.bin}/../tmp/html",
"--write-all",
"-c",
"docs/",
"--doctree-dir",
f"{build_dir}/doctrees",
"docs/",
f"{build_dir}/html",
)
clean()

Expand Down Expand Up @@ -160,19 +166,21 @@ def docs_spellcheck(session: nox.Session) -> None:
Spell-check the package's documentation.
"""
session.install("pyenchant", "sphinxcontrib-spelling", ".[docs]")
session.run_always("pdm", "install", "-dG", "docs", external=True)
session.install("pyenchant", "sphinxcontrib-spelling")
build_dir = session.create_tmp()
session.chdir("docs")
session.run(
f"{session.bin}/python{session.python}",
"-Im",
"sphinx",
"-W", # Promote warnings to errors, so that misspelled words fail the build.
"-b",
"--builder",
"spelling",
"-d",
"-c",
"docs/",
"--doctree-dir",
f"{build_dir}/doctrees",
".",
"docs/",
f"{build_dir}/html",
# On Apple Silicon Macs, this environment variable needs to be set so
# pyenchant can find the "enchant" C library. See
Expand Down Expand Up @@ -281,12 +289,12 @@ def lint_flake8(session: nox.Session) -> None:
@nox.session(python=["3.12"], tags=["linters"])
def lint_pylint(session: nox.Session) -> None:
"""
Lint code with Pyling.
Lint code with Pylint.
"""
# Pylint requires that all dependencies be importable during the run, so unlike
# other lint tasks we just install the package.
session.install(".")
session.run_always("pdm", "install", "-dG", "tests", external=True)
session.install("pylint", "pylint-django")
session.run(f"python{session.python}", "-Im", "pylint", "--version")
session.run(f"python{session.python}", "-Im", "pylint", "src/", "tests/")
Expand Down
Loading

0 comments on commit 9a09383

Please sign in to comment.