From 23e1a17cc7beb13b55a61fd2a5411e18502e4cd5 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:10:48 +0100 Subject: [PATCH 01/12] Add pixi-build --- template/.github/workflows/build.yml | 11 +++++++++++ template/.github/workflows/ci.yml.jinja | 2 -- template/pixi.toml.jinja | 21 ++++++++++----------- template/pyproject.toml.jinja | 9 ++++----- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/template/.github/workflows/build.yml b/template/.github/workflows/build.yml index a68f69e..cd3d9fc 100644 --- a/template/.github/workflows/build.yml +++ b/template/.github/workflows/build.yml @@ -20,6 +20,17 @@ jobs: uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4 with: environments: build + - name: Derive version + id: version + if: startsWith(github.ref, 'refs/tags/') + shell: bash + run: echo "version=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_OUTPUT + - name: Replace version + if: startsWith(github.ref, 'refs/tags/') + run: | + sed -i -e "s/0.0.0/${STEPS_VERSION_OUTPUTS_VERSION}/g" pyproject.toml + env: + STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }} - name: Build project run: pixi run -e build build-wheel - name: Check package diff --git a/template/.github/workflows/ci.yml.jinja b/template/.github/workflows/ci.yml.jinja index fd66ce5..55e1d8c 100644 --- a/template/.github/workflows/ci.yml.jinja +++ b/template/.github/workflows/ci.yml.jinja @@ -55,8 +55,6 @@ jobs: uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4 with: environments: ${{ matrix.environment }} - - name: Install repository - run: pixi run -e ${{ matrix.environment }} postinstall - name: Run pytest run: pixi run -e ${{ matrix.environment }} test-coverage --color=yes {%- endraw %} diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index 3408126..d730d94 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -3,14 +3,17 @@ name = "{{ project_slug }}" channels = ["conda-forge"] platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"] -[tasks] -postinstall = "pip install --no-build-isolation --no-deps --disable-pip-version-check -e ." +[package] +name = "{{ project_slug }}" +[package.build.backend] +name = "pixi-build-python" +version = "*" +[package.host-dependencies] +python = ">={{ minimal_python_version.replace('py3', '3.') }}" +hatchling = "*" [dependencies] -python = ">={{ minimal_python_version.replace('py3', '3.') }}" -pip = "*" -setuptools = ">=61" -setuptools-scm = "*" +{{ project_slug if "." not in project_slug else ('"' ~ project_slug ~ '"') }} = { path = "." } [feature.test.dependencies] pytest = ">=6" @@ -55,7 +58,7 @@ python = "3.14.*" {%- endif %} [environments] -default = ["test", "lint"] +default = ["test", "build", "lint"] {%- if minimal_python_version <= "py310" %} py310 = ["py310", "test"] {%- endif %} @@ -71,7 +74,3 @@ py313 = ["py313", "test"] {%- if minimal_python_version <= "py314" %} py314 = ["py314", "test"] {%- endif %} -{%- if build_docs %} -docs = ["docs"] -{%- endif %} -build = ["build"] diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index ec7364a..8fb0514 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -1,14 +1,13 @@ [build-system] -requires = ["setuptools", "setuptools-scm", "wheel"] - -[tool.setuptools_scm] -version_scheme = "post-release" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "{{ project_slug }}" description = "{{ project_short_description }}" authors = [{ name = "{{ author_name }}", email = "{{ author_email }}" }] -dynamic = ["version"] +# replaced in CI +version = "0.0.0" classifiers = [ "Programming Language :: Python :: 3", {%- if minimal_python_version <= "py310" %} From 7f8407cf274fce3fa651023a984df89f13e38f6d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:11:32 +0100 Subject: [PATCH 02/12] fix --- template/pixi.toml.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index d730d94..a84262d 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -2,6 +2,7 @@ name = "{{ project_slug }}" channels = ["conda-forge"] platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"] +preview = ["pixi-build"] [package] name = "{{ project_slug }}" From b7cb841f4a734e87aa43fc47999eb54bdaf85ecb Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:13:06 +0100 Subject: [PATCH 03/12] fix --- template/.github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/template/.github/workflows/build.yml b/template/.github/workflows/build.yml index cd3d9fc..596bfba 100644 --- a/template/.github/workflows/build.yml +++ b/template/.github/workflows/build.yml @@ -18,8 +18,6 @@ jobs: fetch-depth: 0 - name: Set up pixi uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4 - with: - environments: build - name: Derive version id: version if: startsWith(github.ref, 'refs/tags/') From 89be97528038ffc194dd5bff81cdd76c0aa8dcf3 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:16:21 +0100 Subject: [PATCH 04/12] fiix --- template/.github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/.github/workflows/build.yml b/template/.github/workflows/build.yml index 596bfba..81d72db 100644 --- a/template/.github/workflows/build.yml +++ b/template/.github/workflows/build.yml @@ -30,9 +30,9 @@ jobs: env: STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }} - name: Build project - run: pixi run -e build build-wheel + run: pixi run build-wheel - name: Check package - run: pixi run -e build check-wheel + run: pixi run check-wheel - name: Upload package uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: From f12a5b66ffe1ace0f6e417b3d52853442f312f70 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:19:33 +0100 Subject: [PATCH 05/12] fix --- template/pixi.toml.jinja | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index a84262d..c8696d4 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -25,6 +25,8 @@ test = "pytest" test-coverage = "pytest --cov={{ project_slug_snake_case }} --cov-report=xml --cov-report=term-missing" [feature.build.dependencies] +python = "*" +hatchling = "*" python-build = "*" twine = "*" wheel = "*" From bdbe5dde28b908052f2d9f4b71fe91e7f2c643d1 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:21:41 +0100 Subject: [PATCH 06/12] WIP --- template/pixi.toml.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index c8696d4..df462a1 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -28,7 +28,7 @@ test-coverage = "pytest --cov={{ project_slug_snake_case }} --cov-report=xml --c python = "*" hatchling = "*" python-build = "*" -twine = "*" +twine = ">=6" wheel = "*" [feature.build.tasks] build-wheel = "python -m build --no-isolation ." From 26b2f357477e58047fa094ae3fa51f39722f1a5d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:23:39 +0100 Subject: [PATCH 07/12] unused --- template/pixi.toml.jinja | 1 - 1 file changed, 1 deletion(-) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index df462a1..478e494 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -36,7 +36,6 @@ check-wheel = "twine check dist/*" [feature.lint.dependencies] lefthook = "*" -insert-license-header = "*" docformatter = "*" ruff = "*" prettier = "*" From 8edc4f875e9dcfffc7fb3177470a20dc2506b23e Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:24:05 +0100 Subject: [PATCH 08/12] WIP\ --- template/pixi.toml.jinja | 1 - 1 file changed, 1 deletion(-) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index 478e494..be3ec72 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -29,7 +29,6 @@ python = "*" hatchling = "*" python-build = "*" twine = ">=6" -wheel = "*" [feature.build.tasks] build-wheel = "python -m build --no-isolation ." check-wheel = "twine check dist/*" From 40aa90e045139347c2068a4f4a7acfdfba63ca7d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:31:27 +0100 Subject: [PATCH 09/12] wip --- template/pixi.toml.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index be3ec72..051eb28 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -17,7 +17,7 @@ hatchling = "*" {{ project_slug if "." not in project_slug else ('"' ~ project_slug ~ '"') }} = { path = "." } [feature.test.dependencies] -pytest = ">=6" +pytest = "*" pytest-cov = "*" mypy = "*" [feature.test.tasks] @@ -28,7 +28,7 @@ test-coverage = "pytest --cov={{ project_slug_snake_case }} --cov-report=xml --c python = "*" hatchling = "*" python-build = "*" -twine = ">=6" +twine = "*" [feature.build.tasks] build-wheel = "python -m build --no-isolation ." check-wheel = "twine check dist/*" From 57be2c51f54f8ee085222011d0523126bc4b476d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:33:41 +0100 Subject: [PATCH 10/12] no tasks --- copier.yml | 4 ---- tasks/__init__.py | 6 ------ tasks/__main__.py | 19 ------------------- tasks/git_init.py | 27 --------------------------- tests/test_tasks.py | 26 -------------------------- 5 files changed, 82 deletions(-) delete mode 100644 tasks/__init__.py delete mode 100644 tasks/__main__.py delete mode 100644 tasks/git_init.py delete mode 100644 tests/test_tasks.py diff --git a/copier.yml b/copier.yml index 467deca..79cb2d1 100644 --- a/copier.yml +++ b/copier.yml @@ -62,7 +62,3 @@ add_autobump_workflow: type: bool help: Do you want to add a GitHub Workflow to automatically bump `pixi.lock`? default: true - -_tasks: - - '"{{ _copier_python }}" -I -c "import sys; sys.path.insert(0, \"{{ _copier_conf.src_path }}\"); import runpy; - runpy.run_module(\"tasks\", run_name=\"__main__\")"' diff --git a/tasks/__init__.py b/tasks/__init__.py deleted file mode 100644 index 40014a0..0000000 --- a/tasks/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) QuantCo 2023-2024 -# SPDX-License-Identifier: LicenseRef-QuantCo - -from .git_init import GitInitTask - -__all__ = ["GitInitTask"] diff --git a/tasks/__main__.py b/tasks/__main__.py deleted file mode 100644 index 7b2aef5..0000000 --- a/tasks/__main__.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) QuantCo 2023-2024 -# SPDX-License-Identifier: LicenseRef-QuantCo - -import logging - -from . import GitInitTask - -tasks = [GitInitTask()] - - -def main(): - logging.basicConfig(level=logging.WARNING) - - for task in tasks: - task.run() - - -if __name__ == "__main__": - main() diff --git a/tasks/git_init.py b/tasks/git_init.py deleted file mode 100644 index 170ea89..0000000 --- a/tasks/git_init.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) QuantCo 2023-2024 -# SPDX-License-Identifier: LicenseRef-QuantCo - -import logging -import os -from subprocess import check_output - - -class GitInitTask: - def run(self): - if not os.path.exists(".git"): - git_version = check_output(["git", "--version"]).decode().split()[2] - git_major, git_minor = (int(v) for v in git_version.split(".")[:2]) - git_too_old = (git_major < 2) or (git_major == 2 and git_minor < 28) - # Warn user about --initial-branch option failing for older versions of git - if git_too_old: - logging.warning( - f"Please update your version of git; found version {git_version} " - "when this copier template requires at least 2.28." - ) - check_output(["git", "init", "."]) - else: - check_output(["git", "init", "--initial-branch=main", "."]) - - check_output(["git", "add", "."]) - check_output(["git", "commit", "-m", "Initial project skeleton"]) - check_output(["git", "tag", "0.0.1"]) diff --git a/tests/test_tasks.py b/tests/test_tasks.py deleted file mode 100644 index b722dcf..0000000 --- a/tests/test_tasks.py +++ /dev/null @@ -1,26 +0,0 @@ -from tasks import GitInitTask - -from .utils import change_directory, git_user - - -def test_git_init(tmp_path): - # Create a file for git to add and commit - (tmp_path / "file").touch() - - task = GitInitTask() - with change_directory(tmp_path): - with git_user(): - task.run() - - assert (tmp_path / ".git").is_dir() - - -def test_git_init_already_exists(tmp_path): - (tmp_path / ".git").mkdir() - - task = GitInitTask() - with change_directory(tmp_path): - with git_user(): - task.run() - - # No asserts. We just want no exceptions From 4b84009ed892736ef8b4a38feeab306151aa1a93 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 15:35:02 +0100 Subject: [PATCH 11/12] WIP --- template/pixi.toml.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/pixi.toml.jinja b/template/pixi.toml.jinja index 051eb28..89de794 100644 --- a/template/pixi.toml.jinja +++ b/template/pixi.toml.jinja @@ -28,7 +28,7 @@ test-coverage = "pytest --cov={{ project_slug_snake_case }} --cov-report=xml --c python = "*" hatchling = "*" python-build = "*" -twine = "*" +twine = ">=6" [feature.build.tasks] build-wheel = "python -m build --no-isolation ." check-wheel = "twine check dist/*" From 654912e559aeb0ec85699bb023b060ebc07a5982 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 9 Mar 2026 17:17:50 +0100 Subject: [PATCH 12/12] WIP --- .github/workflows/ci-copier.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-copier.yml b/.github/workflows/ci-copier.yml index dcbfe84..6627b87 100644 --- a/.github/workflows/ci-copier.yml +++ b/.github/workflows/ci-copier.yml @@ -84,12 +84,11 @@ jobs: # Replace actions trigger with on: [push] yq eval '.on = ["push"]' -i .github/workflows/ci.yml yq eval '.on = ["push"]' -i .github/workflows/build.yml - git add .github/workflows/ci.yml .github/workflows/build.yml - git commit -m "Replace actions trigger with on: [push]" + git init # create pixi.lock - pixi list --manifest-path pixi.toml --color=always - git add pixi.lock - git commit -m "Create pixi.lock" + pixi lock --manifest-path pixi.toml --color=always + git add . + git commit -m "Initial commit" # Push the generated package's HEAD commit to a `ci/*` branch cid=$(git rev-parse HEAD) git push -f "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" $cid:refs/heads/${STEPS_BRANCH_OUTPUTS_NAME}