diff --git a/docs/description.md b/docs/description.md index c1ffd131..dd45a9e2 100644 --- a/docs/description.md +++ b/docs/description.md @@ -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) diff --git a/docs/guide.md b/docs/guide.md index 4ca37c0a..bc2d9ec1 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -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 diff --git a/docs/index.md b/docs/index.md index 4e013d94..c294060a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 00000000..084377a0 --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +create = false diff --git a/src/scicookie/cookiecutter.json b/src/scicookie/cookiecutter.json index b3958511..9e1e6b42 100644 --- a/src/scicookie/cookiecutter.json +++ b/src/scicookie/cookiecutter.json @@ -51,7 +51,8 @@ "hatch", "maturin", "scikit-build-core", - "pybind11" + "pybind11", + "pixi" ], "use_bandit": "no", "use_black": "no", diff --git a/src/scicookie/hooks/post_gen_project.py b/src/scicookie/hooks/post_gen_project.py index 65febb70..4c1d4827 100644 --- a/src/scicookie/hooks/post_gen_project.py +++ b/src/scicookie/hooks/post_gen_project.py @@ -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 %} @@ -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", diff --git a/src/scicookie/profiles/base.yaml b/src/scicookie/profiles/base.yaml index fde489d1..0a316317 100644 --- a/src/scicookie/profiles/base.yaml +++ b/src/scicookie/profiles/base.yaml @@ -96,6 +96,7 @@ build_system: - maturin - scikit-build-core - pybind11 + - pixi visible: true command_line_interface: diff --git a/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/main.yaml b/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/main.yaml index 5e883ef3..167648c0 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/main.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/main.yaml @@ -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 %} diff --git a/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/release.yaml b/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/release.yaml index 86d72d8c..10972cef 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/release.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/.github/workflows/release.yaml @@ -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 %} diff --git a/src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml b/src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml index a7e2e2a6..1d29ffe2 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml @@ -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: diff --git a/src/scicookie/{{cookiecutter.project_slug}}/Makefile b/src/scicookie/{{cookiecutter.project_slug}}/Makefile index f5175ac9..5d958ea2 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/Makefile +++ b/src/scicookie/{{cookiecutter.project_slug}}/Makefile @@ -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 diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/dev-deps-pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/dev-deps-pyproject.toml index 8e9c1dd5..dac2cff8 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/dev-deps-pyproject.toml +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/dev-deps-pyproject.toml @@ -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", diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/pyproject.toml index 41271436..ccd925b7 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/pyproject.toml +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/base/pyproject.toml @@ -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"}, @@ -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 ] diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/pixi/pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/pixi/pyproject.toml new file mode 100644 index 00000000..b296c5e7 --- /dev/null +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/pixi/pyproject.toml @@ -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" %} diff --git a/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/conda/dev.yaml b/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/conda/dev.yaml index f4423a06..db046b8b 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/conda/dev.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/conda/dev.yaml @@ -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" %} diff --git a/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/pyenv/requirements.txt b/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/pyenv/requirements.txt index 6d790b88..a00acc2c 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/pyenv/requirements.txt +++ b/src/scicookie/{{cookiecutter.project_slug}}/virtualenvs/pyenv/requirements.txt @@ -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" %} diff --git a/tests/profiles/test-depends-on.yaml b/tests/profiles/test-depends-on.yaml index 6b13872e..dff8261f 100644 --- a/tests/profiles/test-depends-on.yaml +++ b/tests/profiles/test-depends-on.yaml @@ -100,6 +100,7 @@ build_system: - maturin - scikit-build-core - pybind11 + - pixi visible: true command_line_interface: diff --git a/tests/profiles/test-main.yaml b/tests/profiles/test-main.yaml index d5f18e44..cbb06b6f 100644 --- a/tests/profiles/test-main.yaml +++ b/tests/profiles/test-main.yaml @@ -96,6 +96,7 @@ build_system: - maturin - scikit-build-core - pybind11 + - pixi visible: true command_line_interface: diff --git a/tests/smoke/base.sh b/tests/smoke/base.sh index ae255109..ff3d8339 100755 --- a/tests/smoke/base.sh +++ b/tests/smoke/base.sh @@ -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]" @@ -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)" diff --git a/tests/smoke/build-systems.sh b/tests/smoke/build-systems.sh index 6b386cd0..6a37e341 100755 --- a/tests/smoke/build-systems.sh +++ b/tests/smoke/build-systems.sh @@ -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"