Skip to content

Commit 101bb56

Browse files
authored
Setup pixi (#170)
* wip setup pixi project * wip pixi setup: python dependencies and tasks * pixi setup add doc feature * wip pixi setup: add dev tasks * setup pixi: more tweaks * add mypy pixi task * add pixi lock file * ci tests: bump min macos version * add ci workflow: test cpp with pixi (linux) * ci: fix pixi version * ci: pixi fix task name * ci: pixi fix task environment * ci: pixi fix task environment take 2 * doc: add pixi specific details * nit
1 parent 9167287 commit 101bb56

File tree

8 files changed

+9168
-4
lines changed

8 files changed

+9168
-4
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- {os: windows-latest, label: "windows"}
2525
steps:
2626
- name: Checkout repo
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
- name: Set up GCC (Linux)
3030
uses: egor-tensin/setup-gcc@v1
@@ -67,7 +67,7 @@ jobs:
6767
python-version: ["3.10", "3.11", "3.12"]
6868
steps:
6969
- name: Checkout repo
70-
uses: actions/checkout@v3
70+
uses: actions/checkout@v4
7171

7272
- name: Setup micromamba
7373
uses: mamba-org/setup-micromamba@v1
@@ -91,7 +91,7 @@ jobs:
9191
runs-on: ubuntu-latest
9292
steps:
9393
- name: Checkout repo
94-
uses: actions/checkout@v3
94+
uses: actions/checkout@v4
9595

9696
- name: Setup Python
9797
uses: actions/setup-python@v5
@@ -106,3 +106,17 @@ jobs:
106106
run: |
107107
python -m pip install numpy==1.26.4 pytest
108108
pytest python/fastscapelib/tests -vv --color=yes
109+
110+
test_cpp_with_pixi:
111+
name: Test C++ with pixi
112+
runs-on: ubuntu-latest
113+
steps:
114+
- name: Checkout repo
115+
uses: actions/checkout@v4
116+
117+
- uses: prefix-dev/[email protected]
118+
with:
119+
pixi-version: v0.40.1
120+
cache: true
121+
122+
- run: pixi run --environment cpp run-tests

doc/source/build_options.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,75 @@ default). See below for more explanations.
4848
it to build fastscapelib (useful for testing)
4949
```
5050

51+
(pixi-configuration)=
52+
53+
## Pixi Configuration
54+
55+
Fastscapelib provides everything needed to manage its dependencies and run
56+
common tasks via [pixi].
57+
58+
If you have `pixi` installed, you can install a development environment for your
59+
platform simply by executing the following command from Fastscapelib's project
60+
root directory:
61+
62+
```
63+
$ pixi install --environment dev
64+
```
65+
66+
The following environments are defined:
67+
68+
```{list-table}
69+
:widths: 25 75
70+
71+
* - ``build``
72+
- All tools and dependencies needed to build and install Fastscapelib's
73+
core (C++) library.
74+
* - ``cpp``
75+
- For running C++ tests and benchmarks.
76+
* - ``python``
77+
- All tools and dependencies needed to build Fastscapelib's Python bindings
78+
* - ``doc``
79+
- For building Fastscapelib's documentation.
80+
* - ``dev``
81+
- For contributing to Fastscapelib's code (including test and lint tools).
82+
```
83+
84+
Those environments are used to run Fastscapelib's pixi tasks, e.g.,
85+
86+
```
87+
$ pixi run build-python
88+
```
89+
90+
Here is a subset of the available tasks:
91+
92+
```{list-table}
93+
:widths: 25 75
94+
95+
* - ``run-tests``
96+
- Run the C++ tests (build them if needed).
97+
* - ``run-benchmarks``
98+
- Run the benchmarks (build them if needed).
99+
* - ``build-python``
100+
- Build the Python bindings (note the python bindings are built and installed
101+
in the pixi environments during the `pixi install` steps)
102+
* - ``run-tests-python``
103+
- Run the Python bindings tests.
104+
* - ``run-mypy``
105+
- Run the Python static type checker.
106+
* - ``build-doc``
107+
- Build the documentation.
108+
* - ``pre-commit-install``
109+
- Run `pre-commit install` (a set of git hooks that will automatically
110+
check and format the source code prior to each commit)
111+
* - ``update-compile-commands``
112+
- Create of update the compile commands database (useful for C++ LSP
113+
servers)
114+
```
115+
116+
For more details, check the [pixi] documentation. The full pixi configuration
117+
for Fastscapelib can be found in the `pixi.toml` file located in the project
118+
root directory.
119+
51120
(run-cpp-tests)=
52121

53122
## Build and Run the C++ Tests
@@ -139,4 +208,5 @@ $ build/benchmarks/./benchmark_fastscapelib
139208

140209
[google-benchmark]: https://github.com/google/benchmark
141210
[google-test]: https://github.com/google/googletest
211+
[pixi]: https://pixi.sh
142212
[pytest]: https://docs.pytest.org/

doc/source/contributing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ We strongly recommend installing all the dependencies and development tools in a
8585
new [conda](https://conda.io/docs/) environment created specifically for this
8686
project.
8787

88+
:::{note}
89+
If you are using [pixi], setting a development environment is easy! See
90+
{ref}`pixi-configuration`.
91+
:::
92+
8893
You can create a new conda environment with all the dependencies needed for both
8994
C++ and Python development by running the following command from the
9095
repository's root directory:
@@ -259,3 +264,5 @@ following tasks are run automatically using GitHub Actions:
259264
- run pre-commit to check for code formatting inconsistencies
260265
- run mypy for checking Python type hints
261266
- build the documentation on readthedocs
267+
268+
[pixi]: https://pixi.sh

doc/source/install.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ in a (CMake) project.
9393

9494
Fastscapelib [conda] packages are available for all stable versions via the
9595
conda-forge channel. You can install Fastscapelib's C++ headers and all the
96-
dependencies using the following command (alternatively you can use [mamba]):
96+
dependencies using the following command (alternatively you can use [mamba] or
97+
[pixi]):
9798

9899
```bash
99100
$ conda install fastscapelib -c conda-forge
@@ -197,6 +198,7 @@ See [scikit-build-core]'s documentation for more available options.
197198
[numpy]: https://numpy.org
198199
[pip]: https://pip.pypa.io
199200
[pybind11]: https://pybind11.readthedocs.io
201+
[pixi]: https://pixi.sh
200202
[xtensor]: https://xtensor.readthedocs.io
201203
[xtensor-python]: https://xtensor-python.readthedocs.io
202204
[scikit-build-core]: https://scikit-build-core.readthedocs.io

0 commit comments

Comments
 (0)