Skip to content

Commit 8e8ea7f

Browse files
authored
Add pixi-build, use hatchling, remove GitInit task (#135)
1 parent 4bff2de commit 8e8ea7f

10 files changed

Lines changed: 36 additions & 113 deletions

File tree

.github/workflows/ci-copier.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ jobs:
8484
# Replace actions trigger with on: [push]
8585
yq eval '.on = ["push"]' -i .github/workflows/ci.yml
8686
yq eval '.on = ["push"]' -i .github/workflows/build.yml
87-
git add .github/workflows/ci.yml .github/workflows/build.yml
88-
git commit -m "Replace actions trigger with on: [push]"
87+
git init
8988
# create pixi.lock
90-
pixi list --manifest-path pixi.toml --color=always
91-
git add pixi.lock
92-
git commit -m "Create pixi.lock"
89+
pixi lock --manifest-path pixi.toml --color=always
90+
git add .
91+
git commit -m "Initial commit"
9392
# Push the generated package's HEAD commit to a `ci/*` branch
9493
cid=$(git rev-parse HEAD)
9594
git push -f "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" $cid:refs/heads/${STEPS_BRANCH_OUTPUTS_NAME}

copier.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,3 @@ add_autobump_workflow:
6262
type: bool
6363
help: Do you want to add a GitHub Workflow to automatically bump `pixi.lock`?
6464
default: true
65-
66-
_tasks:
67-
- '"{{ _copier_python }}" -I -c "import sys; sys.path.insert(0, \"{{ _copier_conf.src_path }}\"); import runpy;
68-
runpy.run_module(\"tasks\", run_name=\"__main__\")"'

tasks/__init__.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

tasks/__main__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

tasks/git_init.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

template/.github/workflows/build.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ jobs:
1818
fetch-depth: 0
1919
- name: Set up pixi
2020
uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
21-
with:
22-
environments: build
21+
- name: Derive version
22+
id: version
23+
if: startsWith(github.ref, 'refs/tags/')
24+
shell: bash
25+
run: echo "version=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_OUTPUT
26+
- name: Replace version
27+
if: startsWith(github.ref, 'refs/tags/')
28+
run: |
29+
sed -i -e "s/0.0.0/${STEPS_VERSION_OUTPUTS_VERSION}/g" pyproject.toml
30+
env:
31+
STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}
2332
- name: Build project
24-
run: pixi run -e build build-wheel
33+
run: pixi run build-wheel
2534
- name: Check package
26-
run: pixi run -e build check-wheel
35+
run: pixi run check-wheel
2736
- name: Upload package
2837
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
2938
with:

template/.github/workflows/ci.yml.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ jobs:
5555
uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
5656
with:
5757
environments: ${{ matrix.environment }}
58-
- name: Install repository
59-
run: pixi run -e ${{ matrix.environment }} postinstall
6058
- name: Run pytest
6159
run: pixi run -e ${{ matrix.environment }} test-coverage --color=yes
6260
{%- endraw %}

template/pixi.toml.jinja

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,39 @@
22
name = "{{ project_slug }}"
33
channels = ["conda-forge"]
44
platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"]
5+
preview = ["pixi-build"]
56

6-
[tasks]
7-
postinstall = "pip install --no-build-isolation --no-deps --disable-pip-version-check -e ."
7+
[package]
8+
name = "{{ project_slug }}"
9+
[package.build.backend]
10+
name = "pixi-build-python"
11+
version = "*"
12+
[package.host-dependencies]
13+
python = ">={{ minimal_python_version.replace('py3', '3.') }}"
14+
hatchling = "*"
815

916
[dependencies]
10-
python = ">={{ minimal_python_version.replace('py3', '3.') }}"
11-
pip = "*"
12-
setuptools = ">=61"
13-
setuptools-scm = "*"
17+
{{ project_slug if "." not in project_slug else ('"' ~ project_slug ~ '"') }} = { path = "." }
1418

1519
[feature.test.dependencies]
16-
pytest = ">=6"
20+
pytest = "*"
1721
pytest-cov = "*"
1822
mypy = "*"
1923
[feature.test.tasks]
2024
test = "pytest"
2125
test-coverage = "pytest --cov={{ project_slug_snake_case }} --cov-report=xml --cov-report=term-missing"
2226

2327
[feature.build.dependencies]
28+
python = "*"
29+
hatchling = "*"
2430
python-build = "*"
25-
twine = "*"
26-
wheel = "*"
31+
twine = ">=6"
2732
[feature.build.tasks]
2833
build-wheel = "python -m build --no-isolation ."
2934
check-wheel = "twine check dist/*"
3035

3136
[feature.lint.dependencies]
3237
lefthook = "*"
33-
insert-license-header = "*"
3438
docformatter = "*"
3539
ruff = "*"
3640
prettier = "*"
@@ -55,7 +59,7 @@ python = "3.14.*"
5559
{%- endif %}
5660

5761
[environments]
58-
default = ["test", "lint"]
62+
default = ["test", "build", "lint"]
5963
{%- if minimal_python_version <= "py310" %}
6064
py310 = ["py310", "test"]
6165
{%- endif %}
@@ -71,7 +75,3 @@ py313 = ["py313", "test"]
7175
{%- if minimal_python_version <= "py314" %}
7276
py314 = ["py314", "test"]
7377
{%- endif %}
74-
{%- if build_docs %}
75-
docs = ["docs"]
76-
{%- endif %}
77-
build = ["build"]

template/pyproject.toml.jinja

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm", "wheel"]
3-
4-
[tool.setuptools_scm]
5-
version_scheme = "post-release"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
64

75
[project]
86
name = "{{ project_slug }}"
97
description = "{{ project_short_description }}"
108
authors = [{ name = "{{ author_name }}", email = "{{ author_email }}" }]
11-
dynamic = ["version"]
9+
# replaced in CI
10+
version = "0.0.0"
1211
classifiers = [
1312
"Programming Language :: Python :: 3",
1413
{%- if minimal_python_version <= "py310" %}

tests/test_tasks.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)