build: migrate from Poetry to uv

This commit is contained in:
Sigurd Spieckermann 2025-04-09 09:29:14 +02:00 committed by Sigurd Spieckermann
parent a812e14033
commit f374fd9baa
15 changed files with 1610 additions and 448 deletions

16
.envrc
View File

@ -1,17 +1 @@
# SEE https://github.com/direnv/direnv/wiki/Python#poetry
layout_poetry() {
VIRTUAL_ENV=$(poetry env info --path 2>/dev/null ; true)
if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then
log_status "No virtual environment exists. Executing \`poetry install\` to create one."
poetry install --with dev,docs
VIRTUAL_ENV=$(poetry env info --path)
fi
PATH_add "$VIRTUAL_ENV/bin"
export POETRY_ACTIVE=1
export VIRTUAL_ENV
}
use flake . --impure --accept-flake-config --extra-experimental-features 'nix-command flakes' use flake . --impure --accept-flake-config --extra-experimental-features 'nix-command flakes'
layout_poetry

View File

@ -16,12 +16,11 @@ on:
env: env:
LANG: "en_US.utf-8" LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8" LC_ALL: "en_US.utf-8"
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry
POETRY_VIRTUALENVS_IN_PROJECT: "true"
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }} PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
PYTHONIOENCODING: "UTF-8" PYTHONIOENCODING: "UTF-8"
# renovate: datasource=pypi depName=uv
UV_VERSION: "0.6.13"
jobs: jobs:
build: build:
@ -35,46 +34,23 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
# HACK https://github.com/actions/cache/issues/315
- name: Enable msys binaries
if: ${{ runner.os == 'Windows' }}
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm C:\msys64\usr\bin\bash.exe
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Needs all tags to compute dynamic version fetch-depth: 0 # Needs all tags to compute dynamic version
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: "true"
cache-suffix: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get full Python version
id: full-python-version
shell: bash # Required for use of $GITHUB_OUTPUT in windows
run:
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
.cache
.venv
# prettier-ignore
key:
cache-
${{ runner.os }}-
${{ runner.arch }}-
${{ steps.full-python-version.outputs.version }}-
${{ hashFiles('pyproject.toml') }}-
${{ hashFiles('poetry.lock') }}-
${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies - name: Install dependencies
run: | run: uv sync --frozen
python -m pip install poetry poetry-dynamic-versioning
poetry install --with dev,docs -v
- name: Run pytest - name: Run pytest
run: poetry run poe test --cov=./ --cov-report=xml -ra . run: uv run poe test --cov=./ --cov-report=xml -ra .
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
continue-on-error: true continue-on-error: true
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v5
@ -102,25 +78,27 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# Install Nix and set up Cachix # Install Nix
- uses: cachix/install-nix-action@v31 - uses: cachix/install-nix-action@v31
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
# Set up Cachix
- uses: cachix/cachix-action@v16 - uses: cachix/cachix-action@v16
with: with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
extraPullNames: devenv extraPullNames: devenv
name: copier name: copier
pushFilter: (-source$|nixpkgs\.tar\.gz$) pushFilter: (-source$|nixpkgs\.tar\.gz$)
# Install devenv
- run: nix-env -iA devenv -f '<nixpkgs>'
# Cache for poetry venv when using direnv # Cache for uv venv when using direnv
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:
path: | path: |
.cache .cache
.devenv .devenv
.direnv .direnv
.venv
# prettier-ignore # prettier-ignore
key: key:
direnv- direnv-
@ -133,10 +111,10 @@ jobs:
with: with:
install-nix: "false" install-nix: "false"
cache-store: "false" cache-store: "false"
- run: copier --version - run: uv run copier --version
# Run nix checks # Run tests
- run: nix flake check -L --accept-flake-config --impure - run: devenv test
publish: publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
@ -148,36 +126,18 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Needs all tags to compute dynamic version fetch-depth: 0 # Needs all tags to compute dynamic version
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: "true"
cache-suffix: "3.13"
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3.13" python-version: "3.13"
- name: Get full Python version
id: full-python-version
run:
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
.cache
.venv
# prettier-ignore
key:
cache-
${{ runner.os }}-
${{ runner.arch }}-
${{ steps.full-python-version.outputs.version }}-
${{ hashFiles('pyproject.toml') }}-
${{ hashFiles('poetry.lock') }}-
${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry poetry-dynamic-versioning
- name: Build dist - name: Build dist
run: | run: uv build
poetry build
- name: Publish distribution 📦 to Test PyPI - name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master uses: pypa/gh-action-pypi-publish@master
with: with:

View File

@ -1,28 +0,0 @@
name: "Publish tags to FlakeHub"
on:
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
inputs:
tag:
description: "The existing tag to publish to FlakeHub"
type: "string"
required: true
jobs:
flakehub-publish:
runs-on: "ubuntu-latest"
permissions:
id-token: "write"
contents: "read"
steps:
- uses: "actions/checkout@v4"
with:
ref:
"${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || '' }}"
- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
with:
visibility: "public"
name: "copier-org/copier"
tag: "${{ inputs.tag }}"

View File

@ -9,5 +9,7 @@ build:
python: "3.12" python: "3.12"
jobs: jobs:
post_install: post_install:
- pip install poetry - pip install uv
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs - |
VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH \
uv sync --active --frozen --only-group docs

2
.vscode/tasks.json vendored
View File

@ -6,7 +6,7 @@
{ {
"label": "local docs server", "label": "local docs server",
"type": "process", "type": "process",
"command": "poetry", "command": "uv",
"args": ["run", "poe", "docs"], "args": ["run", "poe", "docs"],
"problemMatcher": [] "problemMatcher": []
} }

View File

@ -70,8 +70,8 @@ have enough permissions, you work on Windows, or you just don't want to add yet
package manager to your system. We believe Nix is awesome enough so as to be the default package manager to your system. We believe Nix is awesome enough so as to be the default
tool for almost any developer, but we respect your choice. tool for almost any developer, but we respect your choice.
You can use standard Python tooling such as [Poetry][] and a valid Python installation You can use standard Python tooling such as [uv][] and a valid Python installation
installed in an imperative manner of your choice. installed in an imperative manner of your choice, e.g. using uv as well.
However, you won't be able to auto-lint or auto-format code without Nix. If you don't However, you won't be able to auto-lint or auto-format code without Nix. If you don't
have Nix installed but you have Docker or Podman, you can run `poe lint` and get similar have Nix installed but you have Docker or Podman, you can run `poe lint` and get similar
@ -81,7 +81,7 @@ If you still don't have Docker or Podman, don't worry. You can push your changes
formatting. As long as you give Copier maintainers permissions to change your PR, a bot formatting. As long as you give Copier maintainers permissions to change your PR, a bot
will kindly auto-format code for you and push it back to your branch. will kindly auto-format code for you and push it back to your branch.
[Poetry]: https://python-poetry.org/ [uv]: https://docs.astral.sh/uv/
## Get Started! ## Get Started!
@ -103,7 +103,7 @@ Ready to contribute? Here's how to set up the project for local development.
``` ```
Direnv will take some time to load for the 1st time. It will download all Direnv will take some time to load for the 1st time. It will download all
development dependencies, including [Poetry][], and it will use it to create a development dependencies, including [uv][], and it will use it to create a
virtualenv and install Copier with all its development dependencies too. virtualenv and install Copier with all its development dependencies too.
1. Create a branch for local development: 1. Create a branch for local development:
@ -117,20 +117,20 @@ Ready to contribute? Here's how to set up the project for local development.
1. When you're done making changes, check that your changes pass all tests: 1. When you're done making changes, check that your changes pass all tests:
```shell ```shell
poe test uv run poe test
poe lint uv run poe lint
``` ```
1. Optionally, use pyclean to remove Python bytecode and build artifacts, e.g. 1. Optionally, use pyclean to remove Python bytecode and build artifacts, e.g.
```shell ```shell
pipx run pyclean . --debris --verbose uvx pyclean . --debris --verbose
``` ```
or or
```shell ```shell
uvx pyclean . --debris --verbose pipx run pyclean . --debris --verbose
``` ```
1. Commit your changes and push your branch to GitHub: 1. Commit your changes and push your branch to GitHub:
@ -181,7 +181,7 @@ possible and practical.
To run a subset of tests: To run a subset of tests:
```shell ```shell
poe test tests/the-tests-file.py uv run poe test tests/the-tests-file.py
``` ```
## Nix binary cache ## Nix binary cache

View File

@ -3,7 +3,11 @@
Docs: https://copier.readthedocs.io/ Docs: https://copier.readthedocs.io/
""" """
import importlib.metadata
from .main import * # noqa: F401,F403 from .main import * # noqa: F401,F403
# This version is a placeholder autoupdated by poetry-dynamic-versioning try:
__version__ = "0.0.0" __version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

View File

@ -2,7 +2,5 @@
from .cli import CopierApp from .cli import CopierApp
# HACK https://github.com/nix-community/poetry2nix/issues/504
copier_app_run = CopierApp.run
if __name__ == "__main__": if __name__ == "__main__":
copier_app_run() CopierApp.run()

View File

@ -1,14 +0,0 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{src = ./.;}
)
.defaultNix

View File

@ -13,7 +13,7 @@ def dev_setup() -> None:
"""Set up a development environment.""" """Set up a development environment."""
with local.cwd(HERE): with local.cwd(HERE):
local["direnv"]("allow") local["direnv"]("allow")
local["poetry"]("install") local["uv"]("sync", "--frozen")
def lint() -> None: def lint() -> None:

174
flake.lock generated
View File

@ -40,7 +40,6 @@
}, },
"original": { "original": {
"owner": "cachix", "owner": "cachix",
"ref": "latest",
"repo": "devenv", "repo": "devenv",
"type": "github" "type": "github"
} }
@ -93,38 +92,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-parts_2": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1731533236, "lastModified": 1743550720,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "owner": "hercules-ci",
"revCount": 102, "repo": "flake-parts",
"type": "tarball", "rev": "c621e8422220273271f52058f618c94e405bb0f5",
"url": "https://api.flakehub.com/f/pinned/numtide/flake-utils/0.1.102%2Brev-11707dc2f618dd54ca8739b309ec4fc024de578b/0193276d-5b8f-7dbc-acf1-41cb7b54ad2e/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/numtide/flake-utils/0.1.%2A.tar.gz"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"type": "github" "type": "github"
} }
}, },
@ -207,24 +189,6 @@
"type": "github" "type": "github"
} }
}, },
"nix-github-actions": {
"inputs": {
"nixpkgs": ["poetry2nix", "nixpkgs"]
},
"locked": {
"lastModified": 1729742964,
"narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "e04df33f62cdcf93d73e9a04142464753a16db67",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1733212471, "lastModified": 1733212471,
@ -241,6 +205,37 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"lastModified": 1743296961,
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1744463964,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1717432640, "lastModified": 1717432640,
@ -287,98 +282,13 @@
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz" "url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
} }
}, },
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils_2",
"nix-github-actions": "nix-github-actions",
"nixpkgs": ["nixpkgs"],
"systems": "systems_3",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1743690424,
"narHash": "sha256-cX98bUuKuihOaRp8dNV1Mq7u6/CQZWTPth2IJPATBXc=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "ce2369db77f45688172384bbeb962bc6c2ea6f94",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"devenv": "devenv", "devenv": "devenv",
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
"flake-utils": "flake-utils", "flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_4", "nixpkgs": "nixpkgs_4",
"poetry2nix": "poetry2nix" "nixpkgs-unstable": "nixpkgs-unstable"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": ["poetry2nix", "nixpkgs"]
},
"locked": {
"lastModified": 1730120726,
"narHash": "sha256-LqHYIxMrl/1p3/kvm2ir925tZ8DkI0KA10djk8wecSk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "9ef337e492a5555d8e17a51c911ff1f02635be15",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
} }
} }
}, },

181
flake.nix
View File

@ -17,121 +17,86 @@
# TODO Remove these comments when fixed # TODO Remove these comments when fixed
# github:NixOS/nixpkgs/nixpkgs-24.05 # github:NixOS/nixpkgs/nixpkgs-24.05
}; };
inputs = { inputs = {
devenv.url = "github:cachix/devenv/latest"; devenv.url = "github:cachix/devenv";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.*.tar.gz"; flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.*.tar.gz";
flake-utils.url = "https://flakehub.com/f/numtide/flake-utils/0.1.*.tar.gz"; flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
poetry2nix.url = "github:nix-community/poetry2nix"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = inputs: outputs = inputs @ {
with inputs; flake-parts,
{ devenv,
overlays.default = final: prev: { nixpkgs,
copier = self.packages.${prev.system}.default; nixpkgs-unstable,
}; ...
} }:
// flake-utils.lib.eachDefaultSystem (system: let flake-parts.lib.mkFlake {inherit inputs;} {
pkgs = import nixpkgs { imports = [
inherit system; inputs.devenv.flakeModule
overlays = [poetry2nix.overlays.default]; ];
}; systems = nixpkgs.lib.systems.flakeExposed;
lastRelease = (pkgs.lib.importTOML ./pyproject.toml).tool.commitizen.version;
version = "${lastRelease}.dev${self.sourceInfo.lastModifiedDate}+nix-git-${self.sourceInfo.shortRev or "dirty"}";
python = pkgs.python311;
# Builders perSystem = {
copierApp = let config,
baseApp = pkgs.poetry2nix.mkPoetryApplication { self',
inherit python version; inputs',
name = "copier-${version}"; pkgs,
projectDir = ./.; system,
...
}: {
devenv.shells.default = {
languages.python.enable = true;
languages.python.package = pkgs.python311;
languages.python.uv.enable = true;
languages.python.uv.package = inputs'.nixpkgs-unstable.legacyPackages.uv;
languages.python.uv.sync.enable = true;
# Trick poetry-dynamic-versioning into using our version packages = [
POETRY_DYNAMIC_VERSIONING_BYPASS = version; pkgs.alejandra
pkgs.commitizen
# Test configuration pkgs.mypy
propagatedNativeBuildInputs = [pkgs.git]; pkgs.nodePackages.prettier
pythonImportsCheck = ["copier"]; pkgs.ruff
doCheck = true; pkgs.taplo
installCheckPhase = ''
patchShebangs tests
env \
GIT_AUTHOR_EMAIL=copier@example.com \
GIT_AUTHOR_NAME=copier \
GIT_COMMITTER_EMAIL=copier@example.com \
GIT_COMMITTER_NAME=copier \
PATH=$out/bin:$PATH \
POETRY_VIRTUALENVS_PATH=$NIX_BUILD_TOP/virtualenvs \
PYTHONOPTIMIZE= \
pytest --color=yes -m 'not impure'
'';
};
in
baseApp.overridePythonAttrs (old: {
inherit version;
installCheckPhase = ''
${old.installCheckPhase}
# Make sure version is properly patched in Nix build
test "$(copier --version)" != "copier 0.0.0"
'';
});
copierModule = python.pkgs.toPythonModule copierApp;
in rec {
devShells.default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = with pkgs; [
# Essential dev tools
poetry
python
# IDE integration tools
alejandra
commitizen
mypy
nodePackages.prettier
ruff
taplo
];
difftastic.enable = true;
pre-commit.hooks = {
alejandra.enable = true;
commitizen.enable = true;
editorconfig-checker.enable = true;
editorconfig-checker.excludes = [
"\.md$"
"\.noeof\."
"\.bundle$"
];
prettier.enable = true;
prettier.excludes = [
# Those files have wrong syntax and would fail
"^tests/demo_invalid/copier.yml$"
"^tests/demo_transclude_invalid(_multi)?/demo/copier.yml$"
# HACK https://github.com/prettier/prettier/issues/9430
"^tests/demo"
];
ruff.enable = true;
ruff-format.enable = true;
taplo.enable = true;
};
}
]; ];
};
packages.default = copierModule; difftastic.enable = true;
apps =
builtins.mapAttrs pre-commit.hooks = {
(name: value: flake-utils.lib.mkApp {drv = value;}) alejandra.enable = true;
packages; commitizen.enable = true;
checks = editorconfig-checker.enable = true;
packages editorconfig-checker.excludes = [
// { "\.md$"
devenv-ci = devShells.default.ci; "\.noeof\."
"\.bundle$"
];
prettier.enable = true;
prettier.excludes = [
# Those files have wrong syntax and would fail
"^tests/demo_invalid/copier.yml$"
"^tests/demo_transclude_invalid(_multi)?/demo/copier.yml$"
# HACK https://github.com/prettier/prettier/issues/9430
"^tests/demo"
];
ruff.enable = true;
ruff-format.enable = true;
taplo.enable = true;
}; };
});
enterTest = ''
env \
GIT_AUTHOR_EMAIL=copier@example.com \
GIT_AUTHOR_NAME=copier \
GIT_COMMITTER_EMAIL=copier@example.com \
GIT_COMMITTER_NAME=copier \
PYTHONOPTIMIZE= \
uv run poe test
'';
};
};
};
} }

View File

@ -1,9 +1,9 @@
[tool.poetry] [project]
name = "copier" name = "copier"
# This version is a placeholder autoupdated by poetry-dynamic-versioning dynamic = ["version"]
version = "0.0.0"
description = "A library for rendering project templates." description = "A library for rendering project templates."
license = "MIT" license = { text = "MIT" }
requires-python = ">=3.9"
classifiers = [ classifiers = [
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers", "Intended Audience :: Developers",
@ -15,66 +15,55 @@ classifiers = [
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.13",
] ]
authors = ["Ben Felder <ben@felder.io>"] authors = [{ name = "Ben Felder", email = "ben@felder.io" }]
readme = "README.md"
dependencies = [
"colorama>=0.4.6",
"dunamai>=1.7.0",
"funcy>=1.17",
"jinja2>=3.1.5",
"jinja2-ansible-filters>=1.3.1",
"packaging>=23.0",
"pathspec>=0.9.0",
"plumbum>=1.6.9",
"pydantic>=2.4.2",
"pygments>=2.7.1",
"pyyaml>=5.3.1",
"questionary>=1.8.1",
"eval-type-backport>=0.1.3,<0.3.0; python_version < '3.10'",
"platformdirs>=4.3.6",
"typing-extensions>=4.0.0,<5.0.0; python_version < '3.11'",
]
[project.urls]
homepage = "https://github.com/copier-org/copier" homepage = "https://github.com/copier-org/copier"
repository = "https://github.com/copier-org/copier" repository = "https://github.com/copier-org/copier"
readme = "README.md"
[tool.poetry.scripts]
copier = "copier.__main__:copier_app_run"
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/copier-org/copier/issues" "Bug Tracker" = "https://github.com/copier-org/copier/issues"
[tool.poetry.dependencies] [project.scripts]
python = ">=3.9" copier = "copier.__main__:CopierApp.run"
colorama = ">=0.4.6"
dunamai = ">=1.7.0"
funcy = ">=1.17"
jinja2 = ">=3.1.5"
jinja2-ansible-filters = ">=1.3.1"
packaging = ">=23.0"
pathspec = ">=0.9.0"
plumbum = ">=1.6.9"
pydantic = ">=2.4.2"
pygments = ">=2.7.1"
pyyaml = ">=5.3.1"
questionary = ">=1.8.1"
eval-type-backport = { version = ">=0.1.3,<0.3.0", python = "<3.10" }
platformdirs = ">=4.3.6"
typing-extensions = { version = ">=4.0.0,<5.0.0", python = "<3.11" }
[tool.poetry.group.dev] [dependency-groups]
optional = true dev = [
"mypy>=0.931",
[tool.poetry.group.dev.dependencies] "pexpect>=4.8.0",
mypy = ">=0.931" "poethepoet>=0.12.3",
pexpect = ">=4.8.0" "pre-commit>=2.17.0",
poethepoet = ">=0.12.3" "pytest>=7.2.0",
pre-commit = ">=2.17.0" "pytest-cov>=3.0.0",
pytest = ">=7.2.0" "pytest-gitconfig>=0.6.0",
pytest-cov = ">=3.0.0" "pytest-xdist>=2.5.0",
pytest-gitconfig = ">=0.6.0" "types-backports>=0.1.3",
pytest-xdist = ">=2.5.0" "types-colorama>=0.4",
types-backports = ">=0.1.3" "types-pygments>=2.17",
types-colorama = ">=0.4" "types-pyyaml>=6.0.4",
types-pygments = ">=2.17" "typing-extensions>=3.10.0.0,<5.0.0; python_version < '<3.10'",
types-pyyaml = ">=6.0.4" ]
docs = [
[tool.poetry.group.docs] "markdown-exec>=1.3.0",
optional = true "mkdocs-material>=8.2,<10.0.0",
"mkdocstrings[python]>=0.19.0",
[tool.poetry.group.docs.dependencies] ]
markdown-exec = ">=1.3.0"
mkdocs-material = ">=8.2,<10.0.0"
mkdocstrings = { version = ">=0.19.0", extras = ["python"] }
[tool.poetry.group.build]
# Helper group just for helping nix to build properly
optional = true
[tool.poetry.group.build.dependencies]
poetry-dynamic-versioning = { version = ">=1.1.0", markers = "python_version < '4'" }
[tool.poe.tasks.coverage] [tool.poe.tasks.coverage]
cmd = "pytest --cov-report html --cov copier copier tests" cmd = "pytest --cov-report html --cov copier copier tests"
@ -100,11 +89,6 @@ help = "run tests"
cmd = "mypy ." cmd = "mypy ."
help = "run the type (mypy) checker on the codebase" help = "run the type (mypy) checker on the codebase"
[tool.poetry-dynamic-versioning]
enable = true
style = "pep440"
vcs = "git"
[tool.ruff.lint] [tool.ruff.lint]
extend-select = [ extend-select = [
"ARG", "ARG",
@ -174,6 +158,9 @@ tag_format = "v$version"
update_changelog_on_bump = true update_changelog_on_bump = true
version = "9.6.0" version = "9.6.0"
[tool.hatch.version]
source = "vcs"
[build-system] [build-system]
requires = ["poetry-core>=1.7.0", "poetry-dynamic-versioning>=1.1.0"] requires = ["hatchling", "hatch-vcs"]
build-backend = "poetry_dynamic_versioning.backend" build-backend = "hatchling.build"

View File

@ -38,7 +38,7 @@ COPIER_CMD = local.get(
# HACK https://github.com/microsoft/vscode-python/issues/14222 # HACK https://github.com/microsoft/vscode-python/issues/14222
str(Path(sys.executable).parent / "copier.cmd"), str(Path(sys.executable).parent / "copier.cmd"),
str(Path(sys.executable).parent / "copier"), str(Path(sys.executable).parent / "copier"),
# Poetry installs the executable as copier.cmd in Windows # uv installs the executable as copier.cmd in Windows
"copier.cmd", "copier.cmd",
"copier", "copier",
) )

1394
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff