Skip to content

Commit c5e453d

Browse files
authored
feat: add uv backend (#618)
1 parent c1982ce commit c5e453d

File tree

7 files changed

+48
-27
lines changed

7 files changed

+48
-27
lines changed

.github/workflows/reusable-cookie.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
6060
- name: Test flit
6161
run: nox -s 'tests(flit, novcs)' -s 'tests(flit, vcs)'
6262

63+
- name: Test uv
64+
run: nox -s 'tests(uv, novcs)'
65+
6366
- name: Test pdm
6467
run: nox -s 'tests(pdm, novcs)' -s 'tests(pdm, vcs)'
6568

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,32 @@ hand, from `{{cookiecutter.project_name}}/`).
3939

4040
During generation you can select from the following backends for your package:
4141

42-
1. [hatch][]: This uses hatchling, a modern builder with nice file inclusion,
43-
extendable via plugins, and good error messages. **(Recommended for pure
44-
Python projects)**
45-
2. [flit][]: A modern, lightweight [PEP 621][] build system for pure Python
46-
projects. Replaces setuptools, no MANIFEST.in, setup.py, or setup.cfg. Low
47-
learning curve. Easy to bootstrap into new distributions. Difficult to get
48-
the right files included, little dynamic metadata support.
49-
3. [pdm][]: A modern, less opinionated all-in-one solution to pure Python
50-
projects supporting standards. Replaces setuptools, venv/pipenv, pip, wheel,
51-
and twine. Supports [PEP 621][].
52-
4. [poetry][]: An all-in-one solution to pure Python projects. Replaces
53-
setuptools, venv/pipenv, pip, wheel, and twine. Higher learning curve, but is
54-
all-in-one. Makes some bad default assumptions for libraries.
55-
5. [setuptools][]: The classic build system, but with the new standardized
56-
configuration.
57-
6. [pybind11][]: This is setuptools but with an C++ extension written in
58-
[pybind11][] and wheels generated by [cibuildwheel][].
59-
7. [scikit-build][]: A scikit-build (CMake) project also using pybind11, using
60-
scikit-build-core. **(Recommended for C++ projects)**
61-
8. [meson-python][]: A Meson project also using pybind11. (No VCS versioning)
62-
9. [maturin][]: A [PEP 621][] builder for Rust binary extensions. (No VCS
63-
versioning) **(Recommended for Rust projects)**
42+
1. [hatch][]: This uses hatchling, a modern builder with nice file inclusion,
43+
extendable via plugins, and good error messages. **(Recommended for pure
44+
Python projects)**
45+
2. [uv][]: The `uv_build` backend is written in Rust and is integrated into'
46+
`uv`, meaning it can build without downloading anything extra and can even
47+
avoid running Python at all when building, making it the fastest backend for
48+
simple packages. No dynamic metadata support.
49+
3. [flit][]: A modern, lightweight [PEP 621][] build system for pure Python
50+
projects. Replaces setuptools, no MANIFEST.in, setup.py, or setup.cfg. Low
51+
learning curve. Easy to bootstrap into new distributions. Difficult to get
52+
the right files included, little dynamic metadata support.
53+
4. [pdm][]: A modern, less opinionated all-in-one solution to pure Python
54+
projects supporting standards. Replaces setuptools, venv/pipenv, pip, wheel,
55+
and twine. Supports [PEP 621][].
56+
5. [poetry][]: An all-in-one solution to pure Python projects. Replaces
57+
setuptools, venv/pipenv, pip, wheel, and twine. Higher learning curve, but
58+
is all-in-one. Makes some bad default assumptions for libraries.
59+
6. [setuptools][]: The classic build system, but with the new standardized
60+
configuration.
61+
7. [pybind11][]: This is setuptools but with an C++ extension written in
62+
[pybind11][] and wheels generated by [cibuildwheel][].
63+
8. [scikit-build][]: A scikit-build (CMake) project also using pybind11, using
64+
scikit-build-core. **(Recommended for C++ projects)**
65+
9. [meson-python][]: A Meson project also using pybind11. (No VCS versioning)
66+
10. [maturin][]: A [PEP 621][] builder for Rust binary extensions. (No VCS
67+
versioning) **(Recommended for Rust projects)**
6468

6569
Currently, the best choice is probably hatch for pure Python projects, and
6670
scikit-build (such as the scikit-build-core + pybind11 choice) for binary

cookiecutter.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"license": ["BSD", "Apache", "MIT"],
99
"backend": [
1010
"hatch",
11+
"uv",
1112
"flit",
1213
"pdm",
1314
"poetry",
@@ -34,14 +35,15 @@
3435
"backend": {
3536
"__prompt__": "Choose a build backend",
3637
"hatch": "Hatchling - Pure Python (recommended)",
38+
"uv": "uv_build - Pure Python (fast)",
3739
"flit": "Flit-core - Pure Python (minimal)",
3840
"pdm": "PDM-backend - Pure Python",
3941
"poetry": "Poetry - Pure Python",
4042
"setuptools": "Setuptools - Pure Python",
4143
"pybind11": "Setuptools and pybind11 - Compiled C++",
4244
"skbuild": "Scikit-build-core - Compiled C++ (recommended)",
4345
"mesonpy": "Meson-python - Compiled C++ (also good)",
44-
"maturin": "Maturin - Compiled Rust (recommended)"
46+
"maturin": "Maturin - Compiled Rust (recommended)"
4547
},
4648
"vcs": "Use version control for versioning"
4749
}

copier.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ backend:
7171
help: Choose a build backend
7272
choices:
7373
"Hatchling - Pure Python (recommended)": hatch
74+
"uv_build - Pure Python (fast)": uv
7475
"Flit-core - Pure Python (minimal)": flit
7576
"PDM-backend - Pure Python": pdm
7677
"Poetry - Pure Python": poetry

docs/pages/guides/packaging_simple.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,19 @@ requires = ["hatchling"]
5454
build-backend = "hatchling.build"
5555
```
5656

57+
{% endtab %} {% tab uv uv_build %}
58+
59+
```toml
60+
[build-system]
61+
requires = ["uv_build>=0.7.19"]
62+
build-backend = "uv_build"
63+
```
64+
5765
{% endtab %} {% tab flit Flit-core %}
5866

5967
```toml
6068
[build-system]
61-
requires = ["flit_core>=3.3"]
69+
requires = ["flit_core>=3.12"]
6270
build-backend = "flit_core.buildapi"
6371
```
6472

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def rmtree_ro(path: Path) -> None:
5555

5656

5757
def get_expected_version(backend: str, vcs: bool) -> str:
58-
return "0.2.3" if vcs and backend not in {"maturin", "mesonpy"} else "0.1.0"
58+
return "0.2.3" if vcs and backend not in {"maturin", "mesonpy", "uv"} else "0.1.0"
5959

6060

6161
def make_copier(session: nox.Session, backend: str, vcs: bool) -> None:

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{%- if cookiecutter.backend == "pdm" %}
33
requires = ["pdm-backend>=2.4"]
44
build-backend = "pdm.backend"
5+
{%- elif cookiecutter.backend == "uv" %}
6+
requires = ["uv_build>=0.7.19"]
7+
build-backend = "uv_build"
58
{%- elif cookiecutter.backend == "maturin" %}
69
requires = ["maturin>=1.9,<2"]
710
build-backend = "maturin"
@@ -53,7 +56,7 @@ build-backend = "poetry.core.masonry.api"
5356

5457
[project]
5558
name = "{{ cookiecutter.project_name }}"
56-
{%- if cookiecutter.backend in ['maturin', 'mesonpy'] or not cookiecutter.vcs and cookiecutter.backend in ['setuptools', 'pybind11', 'skbuild', 'poetry'] %}
59+
{%- if cookiecutter.backend in ['maturin', 'mesonpy', 'uv'] or not cookiecutter.vcs and cookiecutter.backend in ['setuptools', 'pybind11', 'skbuild', 'poetry'] %}
5760
version = "0.1.0"
5861
{%- endif %}
5962
authors = [
@@ -102,7 +105,7 @@ classifiers = [
102105
"Topic :: Scientific/Engineering",
103106
"Typing :: Typed",
104107
]
105-
{%- if cookiecutter.backend not in ['maturin', 'mesonpy'] and cookiecutter.vcs or cookiecutter.backend in ['pdm', 'hatch', 'flit'] %}
108+
{%- if cookiecutter.backend not in ['maturin', 'mesonpy', 'uv'] and cookiecutter.vcs or cookiecutter.backend in ['pdm', 'hatch', 'flit'] %}
106109
dynamic = ["version"]
107110
{%- endif %}
108111
dependencies = []

0 commit comments

Comments
 (0)