diff --git a/Dockerfile b/Dockerfile index 3faa405..a2e11c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ ARG PYTHON_VERSION=3.14.3 -ARG PDM_VERSION=2.26.7 ARG COPIER_VERSION=9.14.1 ARG USER_UID=1000 +FROM ghcr.io/astral-sh/uv:0.10.8 AS uv +FROM ghcr.io/casey/just:1.49.0 AS just + FROM python:${PYTHON_VERSION}@sha256:ffebef43892dd36262fa2b042eddd3320d5510a21f8440dce0a650a3c124b51d AS base ARG USER_UID RUN addgroup --system abc && \ @@ -28,34 +30,31 @@ RUN copier copy --defaults . /app/hydrated FROM base AS template-install -ARG PDM_VERSION ARG USER_UID -RUN pip install --user --no-cache-dir pdm==${PDM_VERSION} +COPY --from=uv /uv /usr/local/bin/uv +COPY --from=just /just /usr/local/bin/just COPY --from=template-hydrate --chown=abc:abc /app/hydrated /app/ -RUN --mount=type=cache,target=/home/abc/.cache/pdm,uid=${USER_UID} \ - pdm install +RUN --mount=type=cache,target=/home/abc/.cache/uv,uid=${USER_UID} \ + uv sync FROM template-install AS template-test -RUN pdm test && pdm coverage +RUN just test && just coverage FROM template-install AS template-lint -RUN pdm lint && pdm format +RUN just lint && just format FROM template-install AS template-build -RUN pdm build - -FROM template-install AS template-pex-build -RUN pdm pex-build +RUN just build FROM template-install AS template-clean -RUN pdm clean +RUN just clean FROM template-install AS template-pre-commit ARG USER_UID RUN --mount=type=cache,target=/home/abc/.cache/pre-commit/,uid=${USER_UID} \ git init . && \ git add . && \ - pdm run pre-commit run --all-files + uv run pre-commit run --all-files FROM base AS final # We do not care about the actual results of each stage, we just need to @@ -63,6 +62,5 @@ FROM base AS final COPY --from=template-test --chown=abc:abc /app/pyproject.toml /app COPY --from=template-lint --chown=abc:abc /app/pyproject.toml /app COPY --from=template-build --chown=abc:abc /app/pyproject.toml /app -COPY --from=template-pex-build --chown=abc:abc /app/pyproject.toml /app COPY --from=template-clean --chown=abc:abc /app/pyproject.toml /app COPY --from=template-pre-commit --chown=abc:abc /app/pyproject.toml /app diff --git a/python/.github/actions/common/action.yml b/python/.github/actions/common/action.yml index 8ce0b4c..a52f351 100644 --- a/python/.github/actions/common/action.yml +++ b/python/.github/actions/common/action.yml @@ -7,7 +7,6 @@ runs: - uses: actions/setup-python@v6 with: python-version: "3.14" - - run: pip install pdm - shell: bash - - run: pdm sync + - uses: astral-sh/setup-uv@v6 + - run: uv sync shell: bash diff --git a/python/.github/workflows/lint.yml b/python/.github/workflows/lint.yml index 4c86a60..7ec9b52 100644 --- a/python/.github/workflows/lint.yml +++ b/python/.github/workflows/lint.yml @@ -9,4 +9,7 @@ jobs: steps: - uses: actions/checkout@v5 - uses: ./.github/actions/common - - run: pdm lint + - run: uv run ruff format --check ./src tests/ + - run: uv run ruff check ./src tests/ + - run: uv run ty check src tests + - run: uv lock --check diff --git a/python/.github/workflows/package.yml b/python/.github/workflows/package.yml index eb85cc9..da14c5e 100644 --- a/python/.github/workflows/package.yml +++ b/python/.github/workflows/package.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v5 - uses: ./.github/actions/common - name: Build the Python dist - run: pdm build + run: uv build - name: Export the Python dist uses: actions/upload-artifact@v5 with: diff --git a/python/.github/workflows/pex.yml b/python/.github/workflows/pex.yml deleted file mode 100644 index 68033f8..0000000 --- a/python/.github/workflows/pex.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Build Pex executables -on: - pull_request: - -jobs: - main: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - uses: ./.github/actions/common - - name: Build the Pex executables - run: pdm pex-build - - name: Export the Pex executables - uses: actions/upload-artifact@v5 - with: - name: pex - path: dist/ diff --git a/python/.github/workflows/test.yml b/python/.github/workflows/test.yml index fe8eaae..eee868b 100644 --- a/python/.github/workflows/test.yml +++ b/python/.github/workflows/test.yml @@ -9,4 +9,4 @@ jobs: steps: - uses: actions/checkout@v5 - uses: ./.github/actions/common - - run: pdm test + - run: uv run pytest diff --git a/python/.pre-commit-config.yaml b/python/.pre-commit-config.yaml index 0ae9f29..89693d1 100644 --- a/python/.pre-commit-config.yaml +++ b/python/.pre-commit-config.yaml @@ -18,30 +18,13 @@ repos: rev: v2.14.0 hooks: - id: hadolint - - repo: https://github.com/crate-ci/typos - rev: v1.39.0 + - repo: https://github.com/astral-sh/uv-pre-commit + rev: 0.10.8 hooks: - - id: typos - # Disable auto-fix - args: [] - - repo: https://github.com/pdm-project/pdm - rev: 2.26.7 - hooks: - - id: pdm-lock-check - - repo: https://github.com/pycqa/isort - rev: 7.0.0 - hooks: - - id: isort - - repo: https://github.com/psf/black - rev: 25.12.0 - hooks: - - id: black + - id: uv-lock - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.14.14 hooks: + - id: ruff-format - id: ruff - - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.408 - hooks: - - id: pyright diff --git a/python/Dockerfile.j2 b/python/Dockerfile.j2 index c87554f..0c07ab0 100644 --- a/python/Dockerfile.j2 +++ b/python/Dockerfile.j2 @@ -1,7 +1,18 @@ -ARG PYTHON_VERSION=3.14.3-slim -ARG PDM_VERSION=2.26.7 - -FROM python:${PYTHON_VERSION}@sha256:fb83750094b46fd6b8adaa80f66e2302ecbe45d513f6cece637a841e1025b4ca as base +FROM ghcr.io/astral-sh/uv:debian-slim AS builder +WORKDIR /app +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --frozen --no-install-project --no-dev +COPY ./src /app/src +COPY ./README.md /app/README.md +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --frozen --no-dev + + +FROM debian:bookworm-slim AS final RUN addgroup --system abc && \ adduser \ --shell /bin/sh \ @@ -9,33 +20,8 @@ RUN addgroup --system abc && \ --disabled-password \ abc USER abc -ENV PATH="/home/abc/.local/bin:${PATH}" WORKDIR /app - - -FROM base as base-pdm -ARG PDM_VERSION -RUN pip install --user --no-cache-dir pdm==${PDM_VERSION} -COPY --chown=abc:abc ./pyproject.toml /app/ -COPY --chown=abc:abc ./pdm.lock /app/ - - - -FROM base-pdm as package-builder -COPY --chown=abc:abc ./src /app/src -RUN pdm build --no-sdist - - - -FROM base-pdm as dependencies-installer -RUN pdm sync --production --no-self - - - -FROM base as final +COPY --from=builder --chown=abc:abc /app/.venv /app/.venv ENV PATH="/app/.venv/bin:${PATH}" -COPY --from=dependencies-installer /app/.venv/ /app/.venv/ -COPY --from=package-builder /app/dist/{{ package_name }}*.whl /app/ -RUN pip --python "$(which python)" install --no-cache-dir --no-deps ./{{ package_name }}*.whl ENTRYPOINT [ "{{ package_name }}" ] diff --git a/python/Justfile.j2 b/python/Justfile.j2 new file mode 100644 index 0000000..81e0dd2 --- /dev/null +++ b/python/Justfile.j2 @@ -0,0 +1,52 @@ +# List available recipes +default: + @just --list + +# Format the codebase +format: + uv run ruff format ./src tests/ + +# Run all linters +lint: + uv run ruff format --check ./src tests/ + uv run ruff check ./src tests/ + uv run ty check src tests + uv lock --check + +# Run the test suite +test: + uv run pytest + +# Run tests and generate coverage reports +coverage: + uv run coverage run -m pytest + uv run coverage combine + uv run coverage report + uv run coverage xml + uv run coverage html + +# Install dependencies and pre-commit hooks +setup: + uv sync + uv run pre-commit install + +# Update pre-commit hooks and uv lock +dev-update: + uv run pre-commit autoupdate + uv lock --upgrade + +# Remove build artifacts, caches, and other debris +clean: + uv run pyclean --debris all -- . + +# Build a Docker image of the application +docker-build: + docker build -t {{ package_name }}:dev -t {{ package_name }}:$(uv run python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") . + +# Update the project to the latest version of the template +template-update: + uv run copier update --skip-answered + +# Build distribution packages +build: + uv build diff --git a/python/README.md.j2 b/python/README.md.j2 index 1470d7a..14a0d77 100644 --- a/python/README.md.j2 +++ b/python/README.md.j2 @@ -3,11 +3,9 @@ ![GitHub](https://img.shields.io/github/license/{{ author_username }}/{{ package_name }}) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }}) ![GitHub tag (with filter)](https://img.shields.io/github/v/tag/{{ author_username }}/{{ package_name }}) -![PDM](https://img.shields.io/badge/pdm-managed-blueviolet) -![Black](https://img.shields.io/badge/code_style-black-000000) -![Isort](https://img.shields.io/badge/imports-isort-1674b1?labelColor=ef8336) +![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json) ![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json) -[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/) +![ty](https://img.shields.io/badge/type_checked-ty-blue) ![Pre Commit](https://img.shields.io/badge/pre_commit-enabled-brightgreen?logo=pre-commit) {{ short_description }} @@ -15,7 +13,6 @@ - [Usage](#usage) - [Installation](#installation) - [With `pipx`](#with-pipx) - - [With a `.pex` executable](#with-a-pex-executable) - [With `pip`, from a release version](#with-pip-from-a-release-version) - [With `pip`, from sources](#with-pip-from-sources) - [Development Quickstart](#development-quickstart) @@ -62,17 +59,6 @@ pipx install {{ package_name }}-${VERSION}.tar.gz where `$VERSION` is the version of the package you downloaded. -### With a `.pex` executable - -[`pex`](https://pex.readthedocs.io/en/latest/) is an executable Python -virtualenv format, that can be executed on any machine that provides a suitable -Python interpreter. - -To install the CLI provided by `{{ package_name }}`, download the `.pex` files -of the latest release, and copy them somewhere in your `$PATH` (on Linux, -`~/.local/bin` is often a good idea). The executables will then be available in -your shell. - ### With `pip`, from a release version If you do not wish to use the methods above, you can use `pip` instead. The same diff --git a/python/mise.toml b/python/mise.toml new file mode 100644 index 0000000..d2c1c3a --- /dev/null +++ b/python/mise.toml @@ -0,0 +1,2 @@ +[tools] +uv = "latest" diff --git a/python/pdm.toml b/python/pdm.toml deleted file mode 100644 index 5643f26..0000000 --- a/python/pdm.toml +++ /dev/null @@ -1,2 +0,0 @@ -[strategy] -save = "compatible" diff --git a/python/pyproject.toml.j2 b/python/pyproject.toml.j2 index 515f7c5..de5e60f 100644 --- a/python/pyproject.toml.j2 +++ b/python/pyproject.toml.j2 @@ -1,31 +1,26 @@ -[build-system] -requires = ["setuptools>=73", "wheel"] -build-backend = "setuptools.build_meta" - [project] name = "{{ package_name }}" authors = [{ name = "{{ author_name }}", email = "{{ author_email }}" }] description = "{{ project_name }}" readme = "README.md" -requires-python = ">=3.10,<3.15" +requires-python = ">=3.14,<3.15" license = { text = "MIT" } keywords = [] version = "0.0.1" classifiers = [ "Natural Language :: English", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", - "License :: OSI Approved :: MIT License", ] dependencies = [ "Click==8.3.2", "loguru==0.7.3", ] +[build-system] +requires = ["uv_build>=0.10.8,<0.11"] +build-backend = "uv_build" + [project.urls] Homepage = "{{ repository_url }}" @@ -36,33 +31,20 @@ Issues = "{{ repository_url }}/issues" [project.scripts] {{ package_name }} = "{{ package_name }}.cli:main" -[tool.pyright] -include = ["src", "tests"] -pythonVersion = "3.14" -pythonPlatform = "Linux" -typeCheckingMode = "strict" -venvPath = "." -venv = ".venv" - -[tool.black] -line-length = 100 - -[tool.isort] -profile = "black" -line_length = 100 - [tool.coverage.run] branch = true source = ["{{ package_name }}"] parallel = true [tool.coverage.paths] -source = ["src/", ".tox/**/site-packages"] +source = ["src/"] [tool.ruff] -extend-exclude = ["setup.py"] line-length = 100 +[tool.ruff.format] +docstring-code-format = true + [tool.ruff.lint] select = [ "ERA", # eradicate @@ -94,207 +76,15 @@ convention = "google" [tool.ruff.lint.isort] known-first-party = ["{{ package_name }}"] -[tool.typos.default] -extend-ignore-re = ["_commit:.*"] - -[tool.pdm.scripts] -# Internal helper scripts -_black_format = { cmd = [ - "black", - "./src", - "tests/", -], help = "Format of the code" } -_isort_format = { cmd = [ - "isort", - "./src", - "tests/", -], help = "Format of the imports" } -_black_check = { cmd = [ - "black", - # Do not actually format the code - "--check", - "./src", - "tests/", -], help = "Check the formatting of the code" } -_isort_check = { cmd = [ - "isort", - # Do not actually format the code - "--check", - "./src", - "tests/", -], help = "Check the formatting of the imports" } -_ruff_check = { cmd = [ - "ruff", - # Do not actually fix the code - "check", - "./src", - "tests/", -], help = "Check the overall code" } -_pyright_check = { cmd = [ - "pyright", - "--warnings", -], help = "Check the typing of the code" } -_typos_check = { cmd = [ - "typos", - ".", -], help = "Check the project for any typography" } -_typos_fix = { cmd = [ - "typos", - "--write-changes", - ".", -], help = "Fix any typo found in the project" } -_lockfile_check = { cmd = [ - "pdm", - "lock", - "--check", -], help = "Check that the lockfile is up-to-date" } -_pytest = { cmd = ["pytest"], help = "Run the test suite" } -_coverage_run = { cmd = [ - "coverage", - "run", - "-m", - "pytest", -], help = "Run the test suite and collect the coverage data" } -_coverage_combine = { cmd = [ - "coverage", - "combine", -], help = "Combine all the generated test reports" } -_coverage_report = { cmd = [ - "coverage", - "report", -], help = "Generate a coverage report" } -_coverage_xml = { cmd = [ - "coverage", - "xml", -], help = "Export an XML coverage report" } -_coverage_html = { cmd = [ - "coverage", - "html", -], help = "Export an HTML coverage report" } -_precommit_install = { cmd = [ - "pre-commit", - "install", -], help = "Install the pre-cmmit hooks" } -_precommit_update = { cmd = [ - "pre-commit", - "autoupdate", -], help = "Update the pre-commit hooks to their latest version" } -_packages_install = { cmd = [ - "pdm", - "install", -], help = "Install the package's prod and dev dependencies" } -_dev_packages_update = { cmd = [ - "pdm", - "update", - # Do not touch the prod packages - "--no-default", - # Only touch the dev packages - "--dev", -], help = "Update the dev packages to their latest version" } -_generate_requirements = { cmd = [ - "pdm", - "export", - "--format", - "requirements", - "--prod", - "--output", - "requirements.txt", -], help = "Generate a requirements file for the runtime dependencies" } -_generate_requirements_no_hashes = { cmd = [ - "pdm", - "export", - "--format", - "requirements", - "--prod", - "--without-hashes", - "--output", - "requirements.txt", -], help = "Generate a requirements file for the runtime dependencies" } -_build_pex = { cmd = [ - "python", - "setup.py", - "bdist_pex", - "--bdist-all", - "--pex-args", - "--requirement=requirements.txt", -], help = "Build a PEX file of the package" } -_build_wheel = { cmd = [ - "pdm", - "build", - "--no-sdist", -], help = "Only build the .whl package" } - -# Public scripts -format = { composite = [ - "_black_format", - "_isort_format", -], help = "Format the codebase" } -spell = { composite = [ - "_typos_fix", -], help = "Fix the spelling mistakes found in the project" } -lint = { composite = [ - "_black_check", - "_isort_check", - "_pyright_check", - "_ruff_check", - "_typos_check", - "_lockfile_check", -], help = "Lint the codebase" } -test = { composite = ["_pytest"], help = "Run the test suite" } -coverage = { composite = [ - "_coverage_run", - "_coverage_combine", - "_coverage_report", - "_coverage_xml", - "_coverage_html", -], help = "Measure and report the coverage of the test suite" } -help = { cmd = "pdm run --list", help = "Print the list of existing commands" } -setup = { composite = [ - "_packages_install", - "_precommit_install", -], help = "Install and configure the development environment" } -dev-update = { composite = [ - "_precommit_update", - "_dev_packages_update", -], help = "Update the development dependencies and tools" } -clean = { cmd = [ - "pyclean", - "--debris", - "all", - "--", - ".", -], help = "Remove all the build artifacts, caches, and other debris" } -docker-build = { shell = "docker build -t {{ package_name }}:dev -t {{ package_name }}:$(pdm show --version) .", help = "Build a Docker image of the application" } -pex-build = { composite = [ - "_generate_requirements_no_hashes", - "_build_pex", -], help = "Build a (reproducible) PEX executable of each entrypoint of the application" } -cross-test = { cmd = [ - "tox", - "run-parallel", -], help = "Run the test suite against multiple Python versions" } -template-update = { cmd = [ - "copier", - "update", - '--skip-answered', -], help = "Update the project to the latest version of the template" } - -[tool.pdm.dev-dependencies] +[dependency-groups] dev = [ - "black==25.12.0", "copier==9.14.1", "coverage==7.13.5", - "isort==7.0.0", - "pex==2.90.3", - "pre-commit==4.3.0", - "pyclean==3.4.0", - "pyright==1.1.408", - "pytest==8.4.2", + "pre-commit==4.5.1", + "pyclean==3.6.0", + "pytest==9.0.2", "rope==1.14.0", - "ruff==0.14.14", - "setuptools-scm==9.2.2", + "ruff==0.15.9", "toml==0.10.2", - "tox-pdm==0.7.2", - "tox==4.32.0", - "typos==1.39.0", + "ty==0.0.29", ] diff --git a/python/readme/Quickstart.md b/python/readme/Quickstart.md index 4ec89c7..5fe35af 100644 --- a/python/readme/Quickstart.md +++ b/python/readme/Quickstart.md @@ -7,15 +7,12 @@ template. - [...setup my development environment?](#setup-my-development-environment) - [...get the list of available commands?](#get-the-list-of-available-commands) - [...test my code?](#test-my-code) - - [...test my code against multiple Python versions?](#test-my-code-against-multiple-python-versions) - [...format my code?](#format-my-code) - - [...spellcheck my project?](#spellcheck-my-project) - [...lint my code?](#lint-my-code) - [...generate test coverage?](#generate-test-coverage) - [...add runtime dependencies to my project?](#add-runtime-dependencies-to-my-project) - [...add development dependencies to my project?](#add-development-dependencies-to-my-project) - [...bump the version number of my package?](#bump-the-version-number-of-my-package) - - [...generate a `.pex` executable?](#generate-a-pex-executable) - [...generate a distribution archive?](#generate-a-distribution-archive) - [...build a Docker image that runs my package?](#build-a-docker-image-that-runs-my-package) - [...publish my package to a Pip repository?](#publish-my-package-to-a-pip-repository) @@ -29,15 +26,16 @@ template. These instructions assume that you already have a working development version of Python3 installed on your machine. If this is not the case, start by doing installing one. One recommended method is by using -[pyenv](https://github.com/pyenv/pyenv), a tool that allows you to easily manage -the versions of Python you have installed on your machine. +[mise](https://mise.jdx.dev/), a tool that allows you to easily manage +the versions of Python and other tools you have installed on your machine. -You will then need [`pdm`](https://pdm.fming.dev/latest/) to be installed on -your machine. It is a project, package, and dependency manager for Python, and -is what powers most of this project's lifecycle. The recommended way to install -it is with [`pipx`](https://pypa.github.io/pipx/). +You will also need [`uv`](https://docs.astral.sh/uv/) and +[`just`](https://github.com/casey/just) to be installed on your machine. +`uv` is a fast Python package and project manager, and `just` is a command +runner that powers this project's lifecycle. The recommended way to install +them is via `mise` or your system package manager. -Once Python and `pdm` are available, you can setup the environment with: +Once Python, `uv`, and `just` are available, you can setup the environment with: ``` sh # Clone this repo @@ -46,15 +44,14 @@ git clone {{ repository_url }} cd {{ package_name }} # Create a new virtualenv, install the project, # its dependencies, and the pre-commit hooks -pdm setup +just setup # Check that everything worked as expected by running the linters, # test suite, and building the package # NOTE: This can take a couple of minutes -pdm lint -pdm test -pdm docker-build -pdm build -pdm pex-build +just lint +just test +just docker-build +just build ``` You now have a `virtualenv` in `.venv/` with all the development dependencies @@ -62,104 +59,77 @@ installed, as well as your package installed in development mode. ### ...get the list of available commands? -`pdm help` +`just --list` -This will print the list of `pdm` scripts (defined in `pyproject.toml`), and a +This will print the list of `just` recipes (defined in `Justfile`), and a short description of their purpose. ### ...test my code? -`pdm test` +`just test` This will run the test suite located in the `tests/` directory against the available Python3 install. -### ...test my code against multiple Python versions? - -`pdm cross-test` - -This will use `tox` to test your code against all the Python versions defined in -the `tox.ini` file (make sure to always keep this list consistent with the -`requires-python` and the `classifiers` of the `pyproject.toml`). - -**Note**: You will to have every version of Python to run these tests available -in your `$PATH`. We recommend the use of -[`pyenv`](https://github.com/pyenv/pyenv) to manage your Python versions. - ### ...format my code? -`pdm format` +`just format` -This will run `black` and `isort` on the `src/` and `tests/` directories, +This will run `ruff format` on the `src/` and `tests/` directories, formatting your code properly. -### ...spellcheck my project? - -`pdm spell` - -It will run `typos` on the entire project, and fix any typo it finds. - ### ...lint my code? -`pdm lint` +`just lint` -This will call various linters (`black`, `isort`, `ruff`, `pyright`, `typos`), and +This will call various linters (`ruff`, `ty`), and tell you if your code passes them. ### ...generate test coverage? -`pdm coverage` +`just coverage` This will run the test suite against the available Python3 install, and generate a code coverage report in the `htmlcov` directory. ### ...add runtime dependencies to my project? -`pdm add $PACKAGE` +`uv add $PACKAGE` This will add the requested package to `pyproject.toml`, resolve the all the -dependencies, and lock them in `pdm.lock`. +dependencies, and lock them in `uv.lock`. **Note**: `$PACKAGE` can contain version specifier, such as `"foobar>=2,<3"` ### ...add development dependencies to my project? -`pdm add -d/--dev $PACKAGE` +`uv add --dev $PACKAGE` -Similar to the previous command, this will add the package to different list of +Similar to the previous command, this will add the package to a different list of dependencies, that is only installed when installing the project in development -mode with `pdm`, and not in production. +mode with `uv`, and not in production. ### ...bump the version number of my package? `git tag X.Y.Z` Apply a new `git` tag to the commit you want to define as a new version. When -building the package from the repository, `setuptools_scm` will use this tag as +building the package from the repository, the build backend will use this tag as the version number of the package. Make sure to follow the [Semantic Versioning](https://semver.org/) rule, to always keep a consistent version for your package. -### ...generate a `.pex` executable? - -`pdm pex-build` - -This will generate one `pex` executable archive per entrypoint defined in the -`pyproject.toml` file. Each of this file is a complete `virtualenv`, with the -package and all its dependencies installed inside, and that only need a Python -interpreter to run. - ### ...generate a distribution archive? -`pdm build` +`just build` This will build a `.tar.gz` and a `.whl` distribution files, that can then be installed on a target machine with `pip install $FILENAME`. ### ...build a Docker image that runs my package? -`pdm docker-build` +`just docker-build` This will build a `.whl` distribution, and use it to build a minimal Docker image, tagged `{{ package_name }}:latest` and `{{ package_name }}:$VERSION`, @@ -167,7 +137,7 @@ that runs it. ### ...publish my package to a Pip repository? -`pdm publish` +`uv publish` This will build the `.whl` and `.tar.gz` of the package, and upload them to [Pypi](https://pypi.org). @@ -175,19 +145,19 @@ This will build the `.whl` and `.tar.gz` of the package, and upload them to **Warning**: You must run this command from a properly tagged `git` commit, otherwise your package will be rejected by the repository. -For more control over this process, look at the [documentation of `pdm -publish`](https://pdm.fming.dev/latest/usage/publish/) +For more control over this process, look at the [documentation of `uv +publish`](https://docs.astral.sh/uv/guides/publish/) ### ...clean my local project directory? -`pdm clean` +`just clean` This will use `pyclean` to find and delete the binary python files, the various cache directories, and the `dist/` directory. ### ...update the project to the latest version of the template? -`pdm template-update` +`just template-update` This will update your project to the latest release of the template. Your previous answers to the template questions will be kept, and only the new diff --git a/python/renovate.json b/python/renovate.json index 50e0679..9bbfb6b 100644 --- a/python/renovate.json +++ b/python/renovate.json @@ -22,24 +22,6 @@ ] }, "packageRules": [ - { - "groupName": "typos", - "matchPackageNames": [ - "/typos/" - ] - }, - { - "groupName": "isort", - "matchPackageNames": [ - "/isort/" - ] - }, - { - "groupName": "black", - "matchPackageNames": [ - "/black/" - ] - }, { "groupName": "ruff", "matchPackageNames": [ @@ -47,15 +29,15 @@ ] }, { - "groupName": "pyright", + "groupName": "ty", "matchPackageNames": [ - "/pyright/" + "/ty/" ] }, { - "groupName": "pdm", + "groupName": "uv", "matchPackageNames": [ - "/pdm/" + "/uv/" ] }, { @@ -67,18 +49,5 @@ ], "automerge": true } - ], - "customManagers": [ - { - "customType": "regex", - "fileMatch": [ - "^Dockerfile$" - ], - "matchStrings": [ - "ARG PDM_VERSION=(?.*?)\\n" - ], - "depNameTemplate": "pdm", - "datasourceTemplate": "pypi" - } ] } diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index d45ff34..0000000 --- a/python/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -"""This file is only here to allow older version of setuptools to install this -package. In the future, when we are confident that all these setuptools -versions are gone from the developers and production machines, this file -can be removed. - -See: https://setuptools.pypa.io/en/latest/userguide/declarative_config.html -""" - -from setuptools import setup # type: ignore - -setup() diff --git a/python/tox.ini b/python/tox.ini deleted file mode 100644 index e9d47b6..0000000 --- a/python/tox.ini +++ /dev/null @@ -1,11 +0,0 @@ -[tox] -requires = - tox>=4 -envlist = py3{9,10,11,12,13} -isolated_build = True - -[testenv] -groups = - dev -commands = - pdm test