Skip to content

Commit

Permalink
feat: Adds uv support (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishy7777 authored Feb 8, 2025
1 parent 7934ef3 commit 33fd0bd
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ needs.
- **Project Structure:** Choose between "src" (code in a subdirectory) and
"flat" (all files in the top-level directory) layouts.
- **Packaging & Dependencies:** Supports Poetry, Flit, meson-python, setuptools,
PDM, Hatch, Maturin, scikit-build-core, Pixi, or setuptools + pybind11 for
PDM, Hatch, Maturin, scikit-build-core, Pixi, uv, or setuptools + pybind11 for
flexible build systems.
- **Testing & Linting:** Integrates with pytest and hypothesis (testing), black,
ruff and prettier (auto-formatting), bandit (security), pydocstyle
Expand Down
11 changes: 11 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ packages. SciCookie support the following:
developers to share their projects without worrying about dependency
conflicts.

- [**uv**](https://docs.astral.sh/uv/): An extremely fast Python package and
project manager, written in Rust. A single tool to replace pip, pip-tools,
pipx, poetry, pyenv, twine, virtualenv, and more. 10-100x faster than pip.
Installs and manages Python versions. Runs and installs Python applications.
Runs scripts, with support for inline dependency metadata. Provides
comprehensive project management, with a universal lockfile. Includes a
pip-compatible interface for a performance boost with a familiar CLI. Supports
Cargo-style workspaces for scalable projects. Disk-space efficient, with a
global cache for dependency deduplication. Installable without Rust or Python
via curl or pip. Supports macOS, Linux, and Windows.

The idea behind the options in SciCookie is that you can choose from some of the
most popular system compilers to suit your needs and preferences for developing
Python packages. If you think we should add more options, you can submit your
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Python package.
[meson-python](https://meson-python.readthedocs.io/en/latest/index.html),
[Setuptools](https://setuptools.pypa.io/en/latest/),
[PDM](https://pdm.fming.dev/), [Hatch](https://hatch.pypa.io),
[Pixi](https://pixi.sh/latest/),
[Pixi](https://pixi.sh/latest/), [uv](https://docs.astral.sh/uv/),
[Maturin](https://pypi.org/project/maturin/0.8.2/),
[scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/) or
[setuptools + pybind11](https://pybind11.readthedocs.io/en/stable/) based on
Expand Down
3 changes: 2 additions & 1 deletion src/scicookie/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"maturin",
"scikit-build-core",
"pybind11",
"pixi"
"pixi",
"uv"
],
"use_bandit": "no",
"use_black": "no",
Expand Down
7 changes: 7 additions & 0 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
BUILD_SYSTEM = "pybind11"
{% elif cookiecutter.build_system == "pixi" -%}
BUILD_SYSTEM = "pixi"
{% elif cookiecutter.build_system == "uv" -%}
BUILD_SYSTEM = "uv"
{%- else %}
BUILD_SYSTEM = None
{%- endif %}
Expand Down Expand Up @@ -276,6 +278,11 @@ def clean_up_build_system():
build_system_dir / "pyproject.toml",
PROJECT_DIRECTORY / 'pyproject.toml'
)
elif BUILD_SYSTEM == "uv":
shutil.move(
build_system_dir / "pyproject.toml",
PROJECT_DIRECTORY / 'pyproject.toml'
)
elif BUILD_SYSTEM == "poetry":
shutil.move(
build_system_dir / "pyproject.toml",
Expand Down
1 change: 1 addition & 0 deletions src/scicookie/profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ build_system:
- scikit-build-core
- pybind11
- pixi
- uv
visible: true

command_line_interface:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ jobs:
pdm install
{%- elif cookiecutter.build_system == "pixi" %}
pixi install
{%- elif cookiecutter.build_system == "uv" %}
uv pip install -e .
{%- else %}
pip install .
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
pdm install
{%- elif cookiecutter.build_system == "pixi" %}
pixi install
{%- elif cookiecutter.build_system == "uv" %}
uv install
{%- else %}
pip install .
{%- endif %}
Expand Down
2 changes: 2 additions & 0 deletions src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ groups:
python -m build
{%- elif cookiecutter.build_system == "pixi" %}
pixi run -e dev python -m build
{%- elif cookiecutter.build_system == "uv" %}
python -m build
{%- endif %}
release:
Expand Down
2 changes: 2 additions & 0 deletions src/scicookie/{{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ build:
python -m build
{%- elif cookiecutter.build_system == "pixi" %}
pixi run -e dev python -m build
{%- elif cookiecutter.build_system == "uv" %}
python -m build
{%- endif %}

.PHONY:release-ci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{%- endif %}
dev = [
{#- keep this line here -#}
{%- if cookiecutter.build_system in ["setuptools", "pybind11", "pixi"] %}
{%- if cookiecutter.build_system in ["setuptools", "pybind11", "pixi", "uv"] %}
"build >= 1.2.2",
{%- endif -%}
{%- if cookiecutter.use_pytest == "yes" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = [
{ name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}" },
]
description = "{{ cookiecutter.project_short_description }}"
{% if cookiecutter.build_system not in ["setuptools", "pybind11", "pixi"]%}
{% if cookiecutter.build_system not in ["setuptools", "pybind11", "pixi", "uv"]%}
{% if cookiecutter.project_layout == "src" -%}
packages = [
{include = "{{ cookiecutter.package_slug }}", from="src"},
Expand Down Expand Up @@ -42,7 +42,7 @@ classifiers = [
"Typing :: Typed",
{% endif -%}
]
{% if cookiecutter.build_system in ["scikit-build-core", "pixi"] %}
{% if cookiecutter.build_system in ["scikit-build-core", "pixi", "uv"] %}
version = "{{ cookiecutter.project_version }}"
{% else %}
dynamic = ["version"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["setuptools>=40.8.0", "wheel", "build>=1.2.2"]
build-backend = "setuptools.build_meta"

[tool.uv]
index-url = "https://pypi.org/simple"


{% include "build-system/base/pyproject.toml" %}
{% include "build-system/base/dev-deps-pyproject.toml" %}
{% include "build-system/base/urls-pyproject.toml" %}
{% include "build-system/base/dev-deps-config-pyproject.toml" %}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ dependencies:
- setuptools
- pixi
- python-build
{%- elif cookiecutter.build_system == "uv" %}
- uv
- python-build
{%- endif %}
- nodejs # used by semantic-release
{%- if cookiecutter.use_shellcheck == "yes" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cmake
setuptools
pixi
build
{%- elif cookiecutter.build_system == "uv" %}
uv
build
{%- endif %}
nodejs # used by semantic-release
{%- if cookiecutter.use_shellcheck == "yes" %}
Expand Down
1 change: 1 addition & 0 deletions tests/profiles/test-depends-on.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ build_system:
- scikit-build-core
- pybind11
- pixi
- uv
visible: true

command_line_interface:
Expand Down
1 change: 1 addition & 0 deletions tests/profiles/test-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ build_system:
- scikit-build-core
- pybind11
- pixi
- uv
visible: true

command_line_interface:
Expand Down
2 changes: 2 additions & 0 deletions tests/smoke/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ elif command -v flit &> /dev/null; then
elif command -v pixi &> /dev/null; then
COMMAND_PREFIX="pixi run"
pip install ".[dev]"
elif command -v uv &> /dev/null; then
uv pip install -e ".[dev]"
elif command -v meson &> /dev/null; then
BUILD_SYSTEM="mesonpy"
pip install ".[dev]"
Expand Down
1 change: 1 addition & 0 deletions tests/smoke/build-systems.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. ${SMOKE_DIR}/base.sh "build_system=scikit-build-core"
. ${SMOKE_DIR}/base.sh "build_system=pybind11"
. ${SMOKE_DIR}/base.sh "build_system=pixi"
. ${SMOKE_DIR}/base.sh "build_system=uv"
. ${SMOKE_DIR}/base.sh "build_system=poetry"

0 comments on commit 33fd0bd

Please sign in to comment.