Skip to content

Commit 807e416

Browse files
committed
Switch to pixi and rattler build.
1 parent 0401b90 commit 807e416

9 files changed

Lines changed: 187 additions & 220 deletions

File tree

.github/workflows/devel.yaml

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release Devel
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ devel ]
6+
branches: [devel]
77

88
jobs:
99
build:
@@ -18,11 +18,9 @@ jobs:
1818
- { name: "linux", os: "ubuntu-latest", shell: "bash -l {0}" }
1919
- { name: "macos", os: "macos-latest", shell: "bash -l {0}" }
2020
exclude:
21-
# Exclude all but the latest Python from all
22-
# but Linux
2321
- platform:
2422
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
25-
python-version: "3.12" # MacOS can't run 3.12 yet... We want 3.10 and 3.11
23+
python-version: "3.12" # MacOS can't run 3.12 yet... We want 3.10 and 3.11
2624
environment:
2725
name: ghostly-build
2826
defaults:
@@ -32,30 +30,28 @@ jobs:
3230
SIRE_DONT_PHONEHOME: 1
3331
SIRE_SILENT_PHONEHOME: 1
3432
steps:
35-
- uses: conda-incubator/setup-miniconda@v3
33+
#
34+
- uses: actions/checkout@v4
35+
#
36+
- name: Install rattler-build
37+
uses: prefix-dev/rattler-build-action@v0.2.34
3638
with:
37-
auto-update-conda: true
38-
python-version: ${{ matrix.python-version }}
39-
activate-environment: ghostly_build
40-
miniforge-version: latest
41-
#
42-
- name: Clone the devel branch
43-
run: git clone -b devel https://github.com/openbiosim/ghostly
44-
#
45-
- name: Setup Conda
46-
run: conda install -y -c conda-forge boa anaconda-client packaging
47-
#
48-
- name: Update Conda recipe
49-
run: python ${{ github.workspace }}/ghostly/actions/update_recipe.py
50-
#
51-
- name: Prepare build location
52-
run: mkdir ${{ github.workspace }}/build
53-
#
54-
- name: Build Conda package using conda build
55-
run: conda build -c conda-forge -c openbiosim/label/dev ${{ github.workspace }}/ghostly/recipes/ghostly
56-
#
57-
- name: Upload Conda package
58-
run: python ${{ github.workspace }}/ghostly/actions/upload_package.py
39+
tool-version: latest
40+
build-args: --help
41+
#
42+
- name: Update recipe
43+
run: python ${{ github.workspace }}/actions/update_recipe.py
44+
#
45+
- name: Write Python variant config
46+
shell: bash
47+
run: printf 'python:\n - "${{ matrix.python-version }}"\n' > "${{ github.workspace }}/python_variant.yaml"
48+
#
49+
- name: Build package using rattler-build
50+
shell: bash
51+
run: rattler-build build --recipe "${{ github.workspace }}/recipes/ghostly" -c conda-forge -c openbiosim/label/dev --variant-config "${{ github.workspace }}/python_variant.yaml"
52+
#
53+
- name: Upload package
54+
run: python ${{ github.workspace }}/actions/upload_package.py
5955
env:
6056
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
6157
ANACONDA_LABEL: dev

.github/workflows/main.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
exclude:
2424
- platform:
2525
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
26-
python-version: "3.12" # MacOS can't run 3.12 yet...
26+
python-version: "3.12" # MacOS can't run 3.12 yet...
2727
environment:
2828
name: ghostly-build
2929
defaults:
@@ -33,30 +33,30 @@ jobs:
3333
SIRE_DONT_PHONEHOME: 1
3434
SIRE_SILENT_PHONEHOME: 1
3535
steps:
36-
- uses: conda-incubator/setup-miniconda@v3
36+
#
37+
- uses: actions/checkout@v4
3738
with:
38-
auto-update-conda: true
39-
python-version: ${{ matrix.python-version }}
40-
activate-environment: ghostly_build
41-
miniforge-version: latest
42-
#
43-
- name: Clone the main branch
44-
run: git clone -b main https://github.com/openbiosim/ghostly
45-
#
46-
- name: Setup Conda
47-
run: conda install -y -c conda-forge boa anaconda-client packaging
48-
#
49-
- name: Update Conda recipe
50-
run: python ${{ github.workspace }}/ghostly/actions/update_recipe.py
51-
#
52-
- name: Prepare build location
53-
run: mkdir ${{ github.workspace }}/build
54-
#
55-
- name: Build Conda package using conda build
56-
run: conda build -c conda-forge -c openbiosim/label/main ${{ github.workspace }}/ghostly/recipes/ghostly
57-
#
58-
- name: Upload Conda package
59-
run: python ${{ github.workspace }}/ghostly/actions/upload_package.py
39+
ref: main
40+
#
41+
- name: Install rattler-build
42+
uses: prefix-dev/rattler-build-action@v0.2.34
43+
with:
44+
tool-version: latest
45+
build-args: --help
46+
#
47+
- name: Update recipe
48+
run: python ${{ github.workspace }}/actions/update_recipe.py
49+
#
50+
- name: Write Python variant config
51+
shell: bash
52+
run: printf 'python:\n - "${{ matrix.python-version }}"\n' > "${{ github.workspace }}/python_variant.yaml"
53+
#
54+
- name: Build package using rattler-build
55+
shell: bash
56+
run: rattler-build build --recipe "${{ github.workspace }}/recipes/ghostly" -c conda-forge -c openbiosim/label/main --variant-config "${{ github.workspace }}/python_variant.yaml"
57+
#
58+
- name: Upload package
59+
run: python ${{ github.workspace }}/actions/upload_package.py
6060
env:
6161
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
6262
ANACONDA_LABEL: main

.github/workflows/pr.yaml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ jobs:
1717
- { name: "linux", os: "ubuntu-latest", shell: "bash -l {0}" }
1818
- { name: "macos", os: "macos-latest", shell: "bash -l {0}" }
1919
exclude:
20-
# Exclude all but the latest Python from all
21-
# but Linux
2220
- platform:
2321
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
2422
python-version: "3.10"
2523
- platform:
2624
{ name: "macos", os: "macos-latest", shell: "bash -l {0}" }
27-
python-version: "3.12" # MacOS can't run 3.12 yet...
25+
python-version: "3.12" # MacOS can't run 3.12 yet...
2826
environment:
2927
name: ghostly-build
3028
defaults:
@@ -35,29 +33,28 @@ jobs:
3533
SIRE_SILENT_PHONEHOME: 1
3634
REPO: "${{ github.event.pull_request.head.repo.full_name || github.repository }}"
3735
steps:
38-
- uses: conda-incubator/setup-miniconda@v3
36+
#
37+
- uses: actions/checkout@v4
38+
#
39+
- name: Install rattler-build
40+
uses: prefix-dev/rattler-build-action@v0.2.34
3941
with:
40-
auto-update-conda: true
41-
python-version: ${{ matrix.python-version }}
42-
activate-environment: ghostly_build
43-
miniforge-version: latest
44-
#
45-
- name: Clone the feature branch
46-
run: git clone -b ${{ github.head_ref }} --single-branch https://github.com/${{ env.REPO }} ghostly
47-
#
48-
- name: Setup Conda
49-
run: conda install -y -c conda-forge boa anaconda-client packaging
50-
#
51-
- name: Update Conda recipe
52-
run: python ${{ github.workspace }}/ghostly/actions/update_recipe.py
53-
#
54-
- name: Prepare build location
55-
run: mkdir ${{ github.workspace }}/build
56-
#
57-
- name: Build Conda package using conda build using main channel
42+
tool-version: latest
43+
build-args: --help
44+
#
45+
- name: Update recipe
46+
run: python ${{ github.workspace }}/actions/update_recipe.py
47+
#
48+
- name: Write Python variant config
49+
shell: bash
50+
run: printf 'python:\n - "${{ matrix.python-version }}"\n' > "${{ github.workspace }}/python_variant.yaml"
51+
#
52+
- name: Build package using rattler-build (main channel)
5853
if: ${{ github.base_ref == 'main' }}
59-
run: conda build -c conda-forge -c openbiosim/label/main ${{ github.workspace }}/ghostly/recipes/ghostly
60-
#
61-
- name: Build Conda package using conda build using dev channel
54+
shell: bash
55+
run: rattler-build build --recipe "${{ github.workspace }}/recipes/ghostly" -c conda-forge -c openbiosim/label/main --variant-config "${{ github.workspace }}/python_variant.yaml"
56+
#
57+
- name: Build package using rattler-build (dev channel)
6258
if: ${{ github.base_ref != 'main' }}
63-
run: conda build -c conda-forge -c openbiosim/label/dev ${{ github.workspace }}/ghostly/recipes/ghostly
59+
shell: bash
60+
run: rattler-build build --recipe "${{ github.workspace }}/recipes/ghostly" -c conda-forge -c openbiosim/label/dev --variant-config "${{ github.workspace }}/python_variant.yaml"

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,28 @@ See the [examples](examples) directory for more details.
3030

3131
## Installation
3232

33-
First create a conda environment using the provided environment file:
33+
To install from source, you first need to install
34+
[Sire](https://github.com/OpenBioSim/sire) by following the instructions
35+
[here](https://github.com/OpenBioSim/sire#installation). Once installed,
36+
activate its pixi environment:
3437

3538
```
36-
conda env create -f environment.yaml
39+
pixi shell --manifest-path /path/to/sire/pixi.toml -e dev
3740
```
3841

39-
(We recommend using [Miniforge](https://github.com/conda-forge/miniforge).)
40-
41-
Now install `ghostly` into the environment:
42+
Then install `ghostly` into the environment:
4243

4344
```
44-
conda activate ghostly
4545
pip install .
4646
```
4747

4848
Or, for an editable install (useful for development):
4949

5050
```
51-
conda activate ghostly
5251
pip install -e .
5352
```
5453

55-
For an existing conda environment, you can also install `ghostly` directly from
56-
the `openbiosim` channel:
54+
Alternatively, install `ghostly` directly from the `openbiosim` channel:
5755

5856
```
5957
conda install -c conda-forge -c openbiosim ghostly

actions/update_recipe.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1+
"""Update the rattler-build recipe.yaml with the current git remote and branch."""
2+
13
import sys
24
import os
35
import subprocess
46

5-
# Get the name of the script.
67
script = os.path.abspath(sys.argv[0])
78

8-
# we want to import the 'get_requirements' package from this directory
9-
sys.path.insert(0, os.path.dirname(script))
10-
11-
# go up one directories to get the source directory
12-
# (this script is in BioSimSpace/actions/)
9+
# Go up one directory to get the source directory.
1310
srcdir = os.path.dirname(os.path.dirname(script))
1411

1512
condadir = os.path.join(srcdir, "recipes", "ghostly")
1613

17-
print(f"conda recipe in {condadir}")
14+
print(f"Recipe in {condadir}")
1815

19-
# Store the name of the recipe and template YAML files.
20-
recipe = os.path.join(condadir, "meta.yaml")
21-
template = os.path.join(condadir, "template.yaml")
16+
recipe = os.path.join(condadir, "recipe.yaml")
2217

2318
gitdir = os.path.join(srcdir, ".git")
2419

@@ -32,19 +27,32 @@ def run_cmd(cmd):
3227
remote = run_cmd(
3328
f"git --git-dir={gitdir} --work-tree={srcdir} config --get remote.origin.url"
3429
)
35-
print(remote)
30+
if not remote.endswith(".git"):
31+
remote += ".git"
32+
print(f"Remote: {remote}")
3633

3734
# Get the branch.
3835
branch = run_cmd(
3936
f"git --git-dir={gitdir} --work-tree={srcdir} rev-parse --abbrev-ref HEAD"
4037
)
41-
print(branch)
4238

43-
lines = open(template, "r").readlines()
39+
# Handle detached HEAD (e.g. in GitHub Actions PR checkouts).
40+
if branch == "HEAD":
41+
# GITHUB_HEAD_REF is set for pull_request events.
42+
# GITHUB_REF_NAME is set for push/workflow_dispatch events.
43+
branch = os.environ.get("GITHUB_HEAD_REF") or os.environ.get(
44+
"GITHUB_REF_NAME", "HEAD"
45+
)
46+
print(f"Branch: {branch}")
47+
48+
# Read and update the recipe.
49+
with open(recipe, "r") as f:
50+
content = f.read()
51+
52+
content = content.replace("GHOSTLY_REMOTE", remote)
53+
content = content.replace("GHOSTLY_BRANCH", branch)
4454

45-
with open(recipe, "w") as FILE:
46-
for line in lines:
47-
line = line.replace("GHOSTLY_REMOTE", remote)
48-
line = line.replace("GHOSTLY_BRANCH", branch)
55+
with open(recipe, "w") as f:
56+
f.write(content)
4957

50-
FILE.write(line)
58+
print(f"Recipe updated: {recipe}")

0 commit comments

Comments
 (0)