Skip to content

Commit

Permalink
feat: Add pixi as a build system option to the template (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
YurelyCamacho authored Oct 2, 2024
1 parent 859bfe0 commit f07e14c
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docs/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ 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, or setuptools + pybind11 for flexible
build systems.
PDM, Hatch, Maturin, scikit-build-core, Pixi, or setuptools + pybind11 for
flexible build systems.
- **Testing & Linting:** Integrates with pytest, hypothesis, black
(auto-formatting), bandit (security), pydocstyle (documentation style),
vulture (unused code detection), and McCabe (cyclomatic complexity analysis)
Expand Down
10 changes: 10 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ packages. SciCookie support the following:
game development and automation. Staying up-to-date with the latest pybind11
documentation ensures the best practices are followed.

- [**Pixi**](https://pixi.sh/latest/): Pixi is a package manager designed to
simplify dependency management by creating reproducible development
environments. Pixi focuses on local environments for specific projects,
generating automatic lock-files to ensure that the same dependencies can be
installed across different machines. It also offers a cross-platform task
system for efficient project-specific tasks, such as building, testing, and
more. Pixi supports multiple languages and is designed to make it easy for
developers to share their projects without worrying about dependency
conflicts.

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
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ Python package.
[Setuptools](https://setuptools.pypa.io/en/latest/),
[PDM](https://pdm.fming.dev/), [Hatch](https://hatch.pypa.io),
[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
your preference.
[scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/),
[setuptools + pybind11](https://pybind11.readthedocs.io/en/stable/) or
[Pixi](https://pixi.sh/latest/) based on your preference.
- The structure of the project can use the _src layout_ or _flat layout_. The
“src layout” moving the code that is intended to be importable into a
subdirectory. This subdirectory is typically named src. "Flat layout" refers
Expand Down
2 changes: 2 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
create = false
3 changes: 2 additions & 1 deletion src/scicookie/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"hatch",
"maturin",
"scikit-build-core",
"pybind11"
"pybind11",
"pixi"
],
"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 @@ -91,6 +91,8 @@
BUILD_SYSTEM = "scikit-build-core"
{% elif cookiecutter.build_system == "pybind11" -%}
BUILD_SYSTEM = "pybind11"
{% elif cookiecutter.build_system == "pixi" -%}
BUILD_SYSTEM = "pixi"
{%- else %}
BUILD_SYSTEM = None
{%- endif %}
Expand Down Expand Up @@ -264,6 +266,11 @@ def clean_up_build_system():
build_system_dir / "pyproject.toml",
PROJECT_DIRECTORY / 'pyproject.toml'
)
elif BUILD_SYSTEM == "pixi":
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 @@ -96,6 +96,7 @@ build_system:
- maturin
- scikit-build-core
- pybind11
- pixi
visible: true

command_line_interface:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
flit install
{%- elif cookiecutter.build_system == "pdm" %}
pdm install
{%- elif cookiecutter.build_system == "pixi" %}
pixi install
{%- else %}
pip install .
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
flit install
{%- elif cookiecutter.build_system == "pdm" %}
pdm install
{%- elif cookiecutter.build_system == "pixi" %}
pixi 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 @@ -115,6 +115,8 @@ groups:
maturin build
{%- elif cookiecutter.build_system == "pybind11" %}
python -m build
{%- elif cookiecutter.build_system == "pixi" %}
pixi run -e dev 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 @@ -129,6 +129,8 @@ build:
maturin build
{%- elif cookiecutter.build_system == "pybind11" %}
python -m build
{%- elif cookiecutter.build_system == "pixi" %}
pixi run -e dev python -m build
{%- endif %}

.PHONY:release-ci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
{%- endif %}
dev = [
{#- keep this line here -#}
{%- if cookiecutter.build_system in ["setuptools", "pybind11"] %}
"build>=0.10.0",
{%- if cookiecutter.build_system in ["setuptools", "pybind11", "pixi"] %}
"build >= 1.2.2",
{%- endif -%}
{%- if cookiecutter.use_pytest == "yes" %}
"pytest >= 7.3.2",
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"]%}
{% if cookiecutter.build_system not in ["setuptools", "pybind11", "pixi"]%}
{% if cookiecutter.project_layout == "src" -%}
packages = [
{include = "{{ cookiecutter.package_slug }}", from="src"},
Expand Down Expand Up @@ -43,12 +43,12 @@ classifiers = [
"Typing :: Typed",
{% endif -%}
]
{% if cookiecutter.build_system == "scikit-build-core" %}
{% if cookiecutter.build_system in ["scikit-build-core", "pixi"] %}
version = "{{ cookiecutter.project_version }}"
{% else %}
dynamic = ["version"]
{% endif -%}
requires-python = ">=3.8.1,<4"
requires-python = ">=3.8.6,<4"
dependencies = [
# note: add your dependencies here
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[build-system]
requires = ["setuptools>=40.8.0", "wheel", "build>=1.2.2"]
build-backend = "setuptools.build_meta"

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-arm64", "linux-64"]

[tool.pixi.pypi-dependencies]
"{{ cookiecutter.project_slug }}" = { path = ".", editable = true }

[tool.pixi.dependencies]
python-build = ">=1.2.2"

[tool.pixi.environments]
dev = ["dev"]

{% 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 @@ -27,6 +27,10 @@ dependencies:
{%- elif cookiecutter.build_system == "pybind11" %}
- pybind11
- cmake
{%- elif cookiecutter.build_system == "pixi" %}
- setuptools
- pixi
- 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 @@ -20,6 +20,10 @@ cmake
{%- elif cookiecutter.build_system == "pybind11" %}
pybind11
cmake
{%- elif cookiecutter.build_system == "pixi" %}
setuptools
pixi
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 @@ -100,6 +100,7 @@ build_system:
- maturin
- scikit-build-core
- pybind11
- pixi
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 @@ -96,6 +96,7 @@ build_system:
- maturin
- scikit-build-core
- pybind11
- pixi
visible: true

command_line_interface:
Expand Down
20 changes: 12 additions & 8 deletions tests/smoke/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ export PATH=$(echo $PATH| sed -E "s/[^:]+\/scicookie\/[^:]+//g")

BUILD_SYSTEM="others"

COMMAND_PREFIX=
if command -v poetry &> /dev/null; then
poetry install
elif command -v flit &> /dev/null; then
flit install
elif command -v pixi &> /dev/null; then
COMMAND_PREFIX="pixi run"
pip install ".[dev]"
elif command -v meson &> /dev/null; then
BUILD_SYSTEM="mesonpy"
pip install ".[dev]"
Expand All @@ -54,23 +58,23 @@ else
pip install ".[dev]"
fi

ipython kernel install --name "python3" --user
$COMMAND_PREFIX ipython kernel install --name "python3" --user

if command -v makim &> /dev/null; then
makim tests.linter
makim docs.build
makim package.build
$COMMAND_PREFIX makim tests.linter
$COMMAND_PREFIX makim docs.build
$COMMAND_PREFIX makim package.build
elif command -v make &> /dev/null; then
make lint
make docs-build
make build
$COMMAND_PREFIX make lint
$COMMAND_PREFIX make docs-build
$COMMAND_PREFIX make build
else
echo "Makim and Make were not found in the system."
exit 1

fi

python -c "import osl_python_package as mypkg; assert mypkg.__version__ == '0.1.0'"
$COMMAND_PREFIX python -c 'import osl_python_package as mypkg; assert mypkg.__version__ == "0.1.0"'

if [[ "$BUILD_SYSTEM" == "maturin" ]]; then
python -c "from osl_python_package import add; add(1, 1)"
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 @@ -11,4 +11,5 @@ SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. ${SMOKE_DIR}/base.sh "build_system=maturin"
. ${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=poetry"

0 comments on commit f07e14c

Please sign in to comment.