Skip to content

Commit 57ac5c7

Browse files
authored
Merge pull request #901 from padix-key/pixi
Replace Conda setup with Pixi setup
2 parents 03b3a23 + 8fcec2e commit 57ac5c7

14 files changed

Lines changed: 29062 additions & 199 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
tests/structure/data/* linguist-vendored
22
tests/sequence/data/* linguist-vendored
33
src/biotite/sequence/align/matrix_data/* linguist-vendored
4+
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff

.github/workflows/test_and_deploy.yml

Lines changed: 48 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ env:
2828
--ignore={project}//tests//test_doctest.py
2929
--ignore={project}//tests//test_modname.py
3030
CIBW_DEPENDENCY_VERSIONS: "pinned"
31-
# Configuration for the architecture-agnostic jobs
32-
PY_VERSION: "3.12" # Keep in sync with version in environment.yml
3331

3432

3533
jobs:
@@ -38,27 +36,13 @@ jobs:
3836
runs-on: ubuntu-latest
3937
steps:
4038
- uses: actions/checkout@v4
41-
- uses: actions-rs/toolchain@v1
39+
- uses: prefix-dev/setup-pixi@v0.9.6
4240
with:
43-
toolchain: 1.95.0
44-
override: true
45-
components: rustfmt, clippy
46-
- uses: actions/setup-python@v5
47-
with:
48-
python-version: "3.12"
49-
- name: Install ruff
50-
# Keep in sync with the corresponding versions in pyproject.toml
51-
run: pip install ruff==0.9.7 numpydoc==1.8.0
52-
- name: Check code formatting
53-
run: ruff format --diff
54-
- name: Lint code base
55-
run: ruff check
56-
- name: Check docstring formatting
57-
run: numpydoc lint src/biotite/**/*.py
58-
- name: Check Rust formatting
59-
run: cargo fmt --check
60-
- name: Check Rust lints
61-
run: cargo clippy -- -Dwarnings
41+
environments: lint
42+
cache: true
43+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
44+
- name: Check code style and type annotations
45+
run: pixi run lint
6246

6347

6448
build-internal:
@@ -71,28 +55,14 @@ jobs:
7155
# so 'switcher.py' works correctly in 'docs' job
7256
fetch-depth: 0
7357
fetch-tags: true
74-
- uses: actions/setup-python@v5
58+
- uses: prefix-dev/setup-pixi@v0.9.6
7559
with:
76-
python-version: ${{ env.PY_VERSION }}
77-
- name: Get current CCD for hashing
78-
run: wget https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz
79-
- name: Cache CCD
80-
uses: actions/cache@v4
81-
id: cache-ccd
82-
with:
83-
path: ./src/biotite/structure/info/components.bcif
84-
key: cache-${{ hashFiles('src/biotite/setup_ccd.py') }}-${{ hashFiles('components.cif.gz') }}
85-
- name: Remove CCD used for hashing
86-
run: rm components.cif.gz
87-
- name: Build internal CCD
88-
if: steps.cache-ccd.outputs.cache-hit != 'true'
89-
run: |
90-
pip install -e .
91-
python -m biotite.setup_ccd
92-
- name: Install build backend
93-
run: pip install build
94-
- name: Build distribution
95-
run: python -m build --wheel
60+
environments: test
61+
activate-environment: true
62+
cache: true
63+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
64+
- name: Build CCD and wheel
65+
run: pixi run build-wheel
9666
- uses: actions/upload-artifact@v4
9767
with:
9868
name: internal-build
@@ -201,27 +171,27 @@ jobs:
201171
runs-on: ubuntu-latest
202172
needs:
203173
- build-internal
204-
defaults:
205-
run:
206-
shell: bash -l {0}
207174

208175
steps:
209176
- uses: actions/checkout@v4
210177
- uses: actions/download-artifact@v4
211178
with:
212179
name: internal-build
213180
path: dist
214-
- uses: conda-incubator/setup-miniconda@v3
181+
- uses: prefix-dev/setup-pixi@v0.9.6
215182
with:
216-
environment-file: environment.yml
217-
miniforge-version: latest
218-
- name: Install distribution
219-
run: pip install ./dist/*.whl
183+
environments: test
184+
activate-environment: true
185+
cache: true
186+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
187+
- name: Install pre-built wheel into the pixi environment
188+
# `--no-deps` because conda already provides all runtime dependencies
189+
run: pixi run python -m pip install --no-deps ./dist/*.whl
220190
- name: Run tests
221191
# Running NCBI BLAST and SRA takes too long
222192
# The tests on the NCBI Entrez database are not reliable enough
223193
run: >
224-
pytest
194+
pixi run pytest
225195
--durations=50
226196
--ignore="tests//application//test_blast.py"
227197
--ignore="tests//application//test_sra.py"
@@ -239,27 +209,23 @@ jobs:
239209
runs-on: ubuntu-latest
240210
needs:
241211
- build-internal
242-
defaults:
243-
run:
244-
shell: bash -l {0}
245212

246213
steps:
247214
- uses: actions/checkout@v4
248215
- uses: actions/download-artifact@v4
249216
with:
250217
name: internal-build
251218
path: dist
252-
- uses: conda-incubator/setup-miniconda@v3
219+
- uses: prefix-dev/setup-pixi@v0.9.6
253220
with:
254-
activate-environment: biotite-dev
255-
miniforge-version: latest
256-
python-version: ${{ env.PY_VERSION }}
257-
- name: Install Muscle 5
258-
run: conda install -c bioconda "muscle=5"
259-
- name: Install distribution and pytest
260-
run: pip install .//dist//*.whl pytest
221+
environments: test-muscle5
222+
activate-environment: true
223+
cache: true
224+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
225+
- name: Install pre-built wheel into the pixi environment
226+
run: pixi run python -m pip install --no-deps ./dist/*.whl
261227
- name: Test Muscle 5 interface
262-
run: pytest --durations=50 tests//application//test_msa.py
228+
run: pixi run pytest --durations=50 tests//application//test_msa.py
263229

264230

265231
docs:
@@ -268,9 +234,6 @@ jobs:
268234
runs-on: ubuntu-latest
269235
needs:
270236
- build-internal
271-
defaults:
272-
run:
273-
shell: bash -l {0}
274237
env:
275238
NCBI_API_KEY: ${{ secrets.NCBI_API_KEY }}
276239

@@ -280,10 +243,12 @@ jobs:
280243
with:
281244
name: internal-build
282245
path: dist
283-
- uses: conda-incubator/setup-miniconda@v3
246+
- uses: prefix-dev/setup-pixi@v0.9.6
284247
with:
285-
environment-file: environment.yml
286-
miniforge-version: latest
248+
environments: doc
249+
cache: true
250+
activate-environment: true
251+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
287252
- name: Restore cached partially build docs from a failed previous build
288253
id: cache-docs-restore
289254
uses: actions/cache/restore@v4
@@ -294,18 +259,20 @@ jobs:
294259
doc/examples/gallery
295260
build/doc
296261
build/jupyter_execute
297-
- name: Install distribution
298-
run: pip install dist/*.whl
262+
- name: Install pre-built wheel into the pixi environment
263+
run: pixi run python -m pip install --no-deps ./dist/*.whl
264+
# Calling `sphinx-build` directly instead of `doc` task
265+
# to avoid the time consuming call of the `install` task
299266
- name: Build base documentation
300-
run: sphinx-build -a -D plot_gallery=0 doc build/doc
267+
run: pixi run sphinx-build -a -D plot_gallery=0 doc build/doc
301268
- name: Build tutorial and gallery
302269
if: >
303270
(
304271
github.event_name == 'release' &&
305272
github.event.action == 'published'
306273
)
307274
|| github.event_name == 'workflow_dispatch'
308-
run: sphinx-build -a doc build/doc
275+
run: pixi run sphinx-build -a doc build/doc
309276
- name: Cache partially built docs from failed build
310277
id: cache-docs-save
311278
if: failure()
@@ -340,15 +307,17 @@ jobs:
340307
with:
341308
name: internal-build
342309
path: dist
343-
- uses: actions/setup-python@v5
310+
- uses: prefix-dev/setup-pixi@v0.9.6
344311
with:
345-
python-version: ${{ env.PY_VERSION }}
346-
- name: Install dependencies
347-
run: pip install dist//*.whl pytest pytest-codspeed
312+
environments: test
313+
cache: true
314+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
315+
- name: Install pre-built wheel into the pixi environment
316+
run: pixi run -e test python -m pip install --no-deps ./dist/*.whl
348317
- name: Run benchmarks
349318
uses: CodSpeedHQ/action@v3
350319
with:
351-
run: pytest --codspeed benchmarks
320+
run: pixi run -e test pytest --codspeed benchmarks
352321

353322

354323
upload-package:

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ htmlcov
5656
# Ignore potential directory created during install
5757
biotite.egg-info
5858

59+
# Pixi environments
60+
.pixi/*
61+
62+
# Marker file used by the `_current-date` pixi task
63+
/.date
64+
5965
# Ignore IntelliJ IDEA directory and project files
6066
.idea
6167
*.iml

doc/contribution/development.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ To make code changes ready for a pull request, simply run
6565
$ ruff format
6666
$ ruff check --fix
6767
68-
and fix the remaining linter complaints.
68+
for *Python* code and
69+
70+
.. code-block:: console
71+
72+
$ cargo fmt
73+
$ cargo clippy --fix --allow-dirty
74+
75+
for *Rust* code, and fix the remaining linter complaints.
76+
77+
Equivalently, run
78+
79+
.. code-block:: console
80+
81+
$ pixi run format
82+
83+
in a *Pixi* setup.
6984

7085
Dependencies
7186
------------

doc/contribution/documentation.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ Therefore, the documentation is based on *reStructuredText* files.
1515
The line length of these ``*.rst`` files is also limited to 79 characters
1616
where reasonable.
1717

18-
To build the documentation, run from the root directory of the repository:
18+
To build the documentation, run from the root directory of the repository
1919

2020
.. code-block:: console
2121
2222
$ sphinx-build doc build/doc
2323
24+
or in a ``pixi``-managed environment
25+
26+
.. code-block:: console
27+
28+
$ pixi run doc-full
29+
2430
Documentation structure
2531
-----------------------
2632
*Biotite* employs the
@@ -79,6 +85,12 @@ To build the documentation without the gallery and the tutorial, run
7985
8086
$ sphinx-build -D plot_gallery=0 doc build/doc
8187
88+
or, equivalently,
89+
90+
.. code-block:: console
91+
92+
$ pixi run doc
93+
8294
You may also ask the *Biotite* maintainers to run the example script and check
8395
the generated page, if building the gallery on your device is not possible.
8496

doc/contribution/index.rst

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,37 @@ version of *Biotite*.
3333
Requirements
3434
------------
3535

36-
Development of *Biotite* requires a few packages in addition to the ones
37-
specified in
38-
`pyproject.toml <http://raw.githubusercontent.com/biotite-dev/biotite/master/pyproject.toml>`_.
39-
The full list is provided in
36+
For development of *Biotite* we recommend using the `Pixi <https://pixi.prefix.dev>`_
37+
environment specified in the ``pyproject.toml``.
38+
39+
.. code-block:: console
40+
41+
$ pixi run install
42+
$ pixi shell
43+
44+
The most common workflows are exposed as tasks (run ``pixi task list``
45+
to see all of them), for example:
46+
47+
.. code-block:: console
48+
49+
$ pixi run test
50+
$ pixi run lint
51+
$ pixi run format
52+
$ pixi run doc
53+
54+
Conda setup
55+
^^^^^^^^^^^
56+
57+
If ``conda``/``mamba`` is preferred, the required packages are mirrored in the
4058
`environment.yml <http://raw.githubusercontent.com/biotite-dev/biotite/master/environment.yml>`_.
41-
If you use the `Conda <https://docs.conda.io>`_ package manager, you can simply
42-
create a environment with all required dependencies by running
4359

4460
.. code-block:: console
4561
4662
$ conda env create -f environment.yml
4763
$ conda activate biotite-dev
4864
65+
Note that the `conda` setup is considered deprecated and may be removed in the future.
66+
4967
Contributing examples
5068
---------------------
5169

doc/contribution/testing.rst

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,17 @@ While developing a new feature or fixing a bug, it is handy to run a test
77
script against the code you are working on.
88
To ensure that the imported package ``biotite`` points to the code you are
99
working on, you may want to install the local repository clone in *editable*
10-
mode:
10+
mode via
1111

1212
.. code-block:: console
1313
1414
$ pip install -e .
1515
16-
If you are writing or using an extension module in *Cython*, consider using
17-
`pyximport <https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiling-with-pyximport>`_
18-
at the beginning of the script you use for testing.
16+
or
1917

20-
.. code-block:: python
21-
22-
import numpy as np
23-
import pyximport
24-
pyximport.install(
25-
build_in_temp=False,
26-
setup_args={"include_dirs":np.get_include()},
27-
language_level=3
28-
)
18+
.. code-block:: console
2919
30-
To enforce the recompilation of the changed *Cython* module, delete the
31-
respective compiled module (``.dll`` or ``.so``) from the ``src/`` directory,
32-
if already existing.
20+
$ pixi run install
3321
3422
Unit tests
3523
----------
@@ -44,6 +32,12 @@ run the tests:
4432
$ pip install -e ".[test]"
4533
$ pytest
4634
35+
In a Pixi-managed environment this is equivalent to
36+
37+
.. code-block:: console
38+
39+
$ pixi run test
40+
4741
Benchmarks
4842
----------
4943
As outlined before, computation speed is one of the project's main goals.

doc/examples/scripts/structure/modeling/docking.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
app = autodock.VinaApp(ligand, receptor, ref_ligand_center, [20, 20, 20])
6767
# For reproducibility
6868
app.set_seed(0)
69+
app.set_cpu(1)
6970
# This is the maximum number:
7071
# Vina may find less interesting binding modes
7172
# and thus output less models

0 commit comments

Comments
 (0)