mirror of
https://github.com/copier-org/copier.git
synced 2025-05-05 07:22:55 +00:00
build: migrate from Poetry to uv
This commit is contained in:
parent
a812e14033
commit
f374fd9baa
16
.envrc
16
.envrc
@ -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'
|
||||
layout_poetry
|
||||
|
90
.github/workflows/ci.yml
vendored
90
.github/workflows/ci.yml
vendored
@ -16,12 +16,11 @@ on:
|
||||
env:
|
||||
LANG: "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
|
||||
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
|
||||
PYTHONIOENCODING: "UTF-8"
|
||||
# renovate: datasource=pypi depName=uv
|
||||
UV_VERSION: "0.6.13"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -35,46 +34,23 @@ jobs:
|
||||
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
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
|
||||
with:
|
||||
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 }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
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
|
||||
run: |
|
||||
python -m pip install poetry poetry-dynamic-versioning
|
||||
poetry install --with dev,docs -v
|
||||
run: uv sync --frozen
|
||||
- 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
|
||||
continue-on-error: true
|
||||
uses: codecov/codecov-action@v5
|
||||
@ -102,25 +78,27 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Install Nix and set up Cachix
|
||||
# Install Nix
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
# Set up Cachix
|
||||
- uses: cachix/cachix-action@v16
|
||||
with:
|
||||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
extraPullNames: devenv
|
||||
name: copier
|
||||
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
|
||||
with:
|
||||
path: |
|
||||
.cache
|
||||
.devenv
|
||||
.direnv
|
||||
.venv
|
||||
# prettier-ignore
|
||||
key:
|
||||
direnv-
|
||||
@ -133,10 +111,10 @@ jobs:
|
||||
with:
|
||||
install-nix: "false"
|
||||
cache-store: "false"
|
||||
- run: copier --version
|
||||
- run: uv run copier --version
|
||||
|
||||
# Run nix checks
|
||||
- run: nix flake check -L --accept-flake-config --impure
|
||||
# Run tests
|
||||
- run: devenv test
|
||||
|
||||
publish:
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
@ -148,36 +126,18 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
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
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
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
|
||||
run: |
|
||||
poetry build
|
||||
run: uv build
|
||||
- name: Publish distribution 📦 to Test PyPI
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
|
28
.github/workflows/flakehub-publish-tagged.yml
vendored
28
.github/workflows/flakehub-publish-tagged.yml
vendored
@ -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 }}"
|
@ -9,5 +9,7 @@ build:
|
||||
python: "3.12"
|
||||
jobs:
|
||||
post_install:
|
||||
- pip install poetry
|
||||
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
|
||||
- pip install uv
|
||||
- |
|
||||
VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH \
|
||||
uv sync --active --frozen --only-group docs
|
||||
|
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@ -6,7 +6,7 @@
|
||||
{
|
||||
"label": "local docs server",
|
||||
"type": "process",
|
||||
"command": "poetry",
|
||||
"command": "uv",
|
||||
"args": ["run", "poe", "docs"],
|
||||
"problemMatcher": []
|
||||
}
|
||||
|
@ -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
|
||||
tool for almost any developer, but we respect your choice.
|
||||
|
||||
You can use standard Python tooling such as [Poetry][] and a valid Python installation
|
||||
installed in an imperative manner of your choice.
|
||||
You can use standard Python tooling such as [uv][] and a valid Python installation
|
||||
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
|
||||
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
|
||||
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!
|
||||
|
||||
@ -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
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
```shell
|
||||
poe test
|
||||
poe lint
|
||||
uv run poe test
|
||||
uv run poe lint
|
||||
```
|
||||
|
||||
1. Optionally, use pyclean to remove Python bytecode and build artifacts, e.g.
|
||||
|
||||
```shell
|
||||
pipx run pyclean . --debris --verbose
|
||||
uvx pyclean . --debris --verbose
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```shell
|
||||
uvx pyclean . --debris --verbose
|
||||
pipx run pyclean . --debris --verbose
|
||||
```
|
||||
|
||||
1. Commit your changes and push your branch to GitHub:
|
||||
@ -181,7 +181,7 @@ possible and practical.
|
||||
To run a subset of tests:
|
||||
|
||||
```shell
|
||||
poe test tests/the-tests-file.py
|
||||
uv run poe test tests/the-tests-file.py
|
||||
```
|
||||
|
||||
## Nix binary cache
|
||||
|
@ -3,7 +3,11 @@
|
||||
Docs: https://copier.readthedocs.io/
|
||||
"""
|
||||
|
||||
import importlib.metadata
|
||||
|
||||
from .main import * # noqa: F401,F403
|
||||
|
||||
# This version is a placeholder autoupdated by poetry-dynamic-versioning
|
||||
__version__ = "0.0.0"
|
||||
try:
|
||||
__version__ = importlib.metadata.version(__name__)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
__version__ = "0.0.0"
|
||||
|
@ -2,7 +2,5 @@
|
||||
|
||||
from .cli import CopierApp
|
||||
|
||||
# HACK https://github.com/nix-community/poetry2nix/issues/504
|
||||
copier_app_run = CopierApp.run
|
||||
if __name__ == "__main__":
|
||||
copier_app_run()
|
||||
CopierApp.run()
|
||||
|
14
default.nix
14
default.nix
@ -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
|
@ -13,7 +13,7 @@ def dev_setup() -> None:
|
||||
"""Set up a development environment."""
|
||||
with local.cwd(HERE):
|
||||
local["direnv"]("allow")
|
||||
local["poetry"]("install")
|
||||
local["uv"]("sync", "--frozen")
|
||||
|
||||
|
||||
def lint() -> None:
|
||||
|
174
flake.lock
generated
174
flake.lock
generated
@ -40,7 +40,6 @@
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"ref": "latest",
|
||||
"repo": "devenv",
|
||||
"type": "github"
|
||||
}
|
||||
@ -93,38 +92,21 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"flake-parts_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"revCount": 102,
|
||||
"type": "tarball",
|
||||
"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",
|
||||
"lastModified": 1743550720,
|
||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@ -207,24 +189,6 @@
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1733212471,
|
||||
@ -241,6 +205,37 @@
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1717432640,
|
||||
@ -287,98 +282,13 @@
|
||||
"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": {
|
||||
"inputs": {
|
||||
"devenv": "devenv",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-parts": "flake-parts_2",
|
||||
"nixpkgs": "nixpkgs_4",
|
||||
"poetry2nix": "poetry2nix"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
"nixpkgs-unstable": "nixpkgs-unstable"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
181
flake.nix
181
flake.nix
@ -17,121 +17,86 @@
|
||||
# TODO Remove these comments when fixed
|
||||
# github:NixOS/nixpkgs/nixpkgs-24.05
|
||||
};
|
||||
|
||||
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-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";
|
||||
poetry2nix.url = "github:nix-community/poetry2nix";
|
||||
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
with inputs;
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
copier = self.packages.${prev.system}.default;
|
||||
};
|
||||
}
|
||||
// flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [poetry2nix.overlays.default];
|
||||
};
|
||||
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;
|
||||
outputs = inputs @ {
|
||||
flake-parts,
|
||||
devenv,
|
||||
nixpkgs,
|
||||
nixpkgs-unstable,
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
imports = [
|
||||
inputs.devenv.flakeModule
|
||||
];
|
||||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
|
||||
# Builders
|
||||
copierApp = let
|
||||
baseApp = pkgs.poetry2nix.mkPoetryApplication {
|
||||
inherit python version;
|
||||
name = "copier-${version}";
|
||||
projectDir = ./.;
|
||||
perSystem = {
|
||||
config,
|
||||
self',
|
||||
inputs',
|
||||
pkgs,
|
||||
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
|
||||
POETRY_DYNAMIC_VERSIONING_BYPASS = version;
|
||||
|
||||
# Test configuration
|
||||
propagatedNativeBuildInputs = [pkgs.git];
|
||||
pythonImportsCheck = ["copier"];
|
||||
doCheck = true;
|
||||
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 = [
|
||||
pkgs.alejandra
|
||||
pkgs.commitizen
|
||||
pkgs.mypy
|
||||
pkgs.nodePackages.prettier
|
||||
pkgs.ruff
|
||||
pkgs.taplo
|
||||
];
|
||||
};
|
||||
packages.default = copierModule;
|
||||
apps =
|
||||
builtins.mapAttrs
|
||||
(name: value: flake-utils.lib.mkApp {drv = value;})
|
||||
packages;
|
||||
checks =
|
||||
packages
|
||||
// {
|
||||
devenv-ci = devShells.default.ci;
|
||||
|
||||
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;
|
||||
};
|
||||
});
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
119
pyproject.toml
119
pyproject.toml
@ -1,9 +1,9 @@
|
||||
[tool.poetry]
|
||||
[project]
|
||||
name = "copier"
|
||||
# This version is a placeholder autoupdated by poetry-dynamic-versioning
|
||||
version = "0.0.0"
|
||||
dynamic = ["version"]
|
||||
description = "A library for rendering project templates."
|
||||
license = "MIT"
|
||||
license = { text = "MIT" }
|
||||
requires-python = ">=3.9"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
@ -15,66 +15,55 @@ classifiers = [
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"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"
|
||||
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"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9"
|
||||
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" }
|
||||
[project.scripts]
|
||||
copier = "copier.__main__:CopierApp.run"
|
||||
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
mypy = ">=0.931"
|
||||
pexpect = ">=4.8.0"
|
||||
poethepoet = ">=0.12.3"
|
||||
pre-commit = ">=2.17.0"
|
||||
pytest = ">=7.2.0"
|
||||
pytest-cov = ">=3.0.0"
|
||||
pytest-gitconfig = ">=0.6.0"
|
||||
pytest-xdist = ">=2.5.0"
|
||||
types-backports = ">=0.1.3"
|
||||
types-colorama = ">=0.4"
|
||||
types-pygments = ">=2.17"
|
||||
types-pyyaml = ">=6.0.4"
|
||||
|
||||
[tool.poetry.group.docs]
|
||||
optional = true
|
||||
|
||||
[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'" }
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"mypy>=0.931",
|
||||
"pexpect>=4.8.0",
|
||||
"poethepoet>=0.12.3",
|
||||
"pre-commit>=2.17.0",
|
||||
"pytest>=7.2.0",
|
||||
"pytest-cov>=3.0.0",
|
||||
"pytest-gitconfig>=0.6.0",
|
||||
"pytest-xdist>=2.5.0",
|
||||
"types-backports>=0.1.3",
|
||||
"types-colorama>=0.4",
|
||||
"types-pygments>=2.17",
|
||||
"types-pyyaml>=6.0.4",
|
||||
"typing-extensions>=3.10.0.0,<5.0.0; python_version < '<3.10'",
|
||||
]
|
||||
docs = [
|
||||
"markdown-exec>=1.3.0",
|
||||
"mkdocs-material>=8.2,<10.0.0",
|
||||
"mkdocstrings[python]>=0.19.0",
|
||||
]
|
||||
|
||||
[tool.poe.tasks.coverage]
|
||||
cmd = "pytest --cov-report html --cov copier copier tests"
|
||||
@ -100,11 +89,6 @@ help = "run tests"
|
||||
cmd = "mypy ."
|
||||
help = "run the type (mypy) checker on the codebase"
|
||||
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
style = "pep440"
|
||||
vcs = "git"
|
||||
|
||||
[tool.ruff.lint]
|
||||
extend-select = [
|
||||
"ARG",
|
||||
@ -174,6 +158,9 @@ tag_format = "v$version"
|
||||
update_changelog_on_bump = true
|
||||
version = "9.6.0"
|
||||
|
||||
[tool.hatch.version]
|
||||
source = "vcs"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.7.0", "poetry-dynamic-versioning>=1.1.0"]
|
||||
build-backend = "poetry_dynamic_versioning.backend"
|
||||
requires = ["hatchling", "hatch-vcs"]
|
||||
build-backend = "hatchling.build"
|
||||
|
@ -38,7 +38,7 @@ COPIER_CMD = local.get(
|
||||
# HACK https://github.com/microsoft/vscode-python/issues/14222
|
||||
str(Path(sys.executable).parent / "copier.cmd"),
|
||||
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",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user