Skip to content

Commit

Permalink
added conda workflow
Browse files Browse the repository at this point in the history
- install and run tests using conda
- no deployment yet
  • Loading branch information
GiovanniBussi committed May 20, 2024
1 parent d506d46 commit 9c4adb6
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,59 @@ jobs:
python setup.py sdist
python -m twine upload -u __token__ -p "$MDREFINE_PYPI" dist/MDRefine-*.tar.gz
conda:

strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Install conda
run: |
curl -LO https://raw.githubusercontent.com/GiovanniBussi/conda-ci/master/conda-ci
source ./conda-ci install
source ./conda-ci install-conda-build
- name: Build
run: |
source activate base
python make_conda_recipe.py
export CPU_COUNT=2
conda-build -c conda-forge conda
rm -fr MDRefine # make sure this is not imported by mistake in tests
- name: Test 3.9
run: |
source activate base
conda create -n py39 -c conda-forge -c local python=3.9 MDRefine pytest
source activate py39
pytest -v
- name: Test 3.10
run: |
source activate base
conda create -n py310 -c conda-forge -c local python=3.10 MDRefine pytest
source activate py310
pytest -v
- name: Test 3.11
run: |
source activate base
conda create -n py311 -c conda-forge -c local python=3.11 MDRefine pytest
source activate py311
pytest -v
- name: Test 3.12
run: |
source activate base
conda create -n py312 -c conda-forge -c local python=3.12 MDRefine pytest
source activate py312
pytest -v
- name: Deploy conda
if: ${{ matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/') }}
#env:
# CONDA_UPLOAD_TOKEN: ${{ secrets.CONDA_UPLOAD_TOKEN }}
run: |
#TODO
#source activate base
#anaconda -t $CONDA_UPLOAD_TOKEN upload -u bussilab -l main $CONDA_PREFIX/conda-bld/*/py-bussilab*.tar.bz2 --force
8 changes: 8 additions & 0 deletions conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CONDA_BUILD_SYSROOT:
- /opt/MacOSX10.13.sdk # [osx and x86_64]
- /opt/MacOSX11.0.sdk # [osx and arm64]
python:
- "3.12"
- "3.11"
- "3.10"
- "3.9"
39 changes: 39 additions & 0 deletions conda/meta.yaml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package:
name: mdrefine
version: __VERSION__

source:
path: ..

build:
number: 0
noarch: python
script: "{{ PYTHON }} -m pip install . --no-deps -vv"

requirements:
host:
- python >=3.9
- pip
run:
__REQUIRED__
- python >=3.9

test:
imports:
- MDRefine
#commands:
# - bussilab check --import

about:
home: https://github.com/bussilab/MDRefine
license: LGPL-2.1
license_family: GPL
summary: '__SUMMARY__'
description: |
__DESCRIPTION__
#doc_url: https://bussilab.github.io/doc-py-bussilab
#dev_url: https://github.com/bussilab/py-bussilab

extra:
recipe-maintainers:
- GiovanniBussi
41 changes: 41 additions & 0 deletions make_conda_recipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ast
import re
from MDRefine import _required_
from MDRefine import __version__

def readme():
with open('README.md') as f:
return f.read()

def description():
from MDRefine import __doc__ as doc
return doc.partition('\n')[0]

with open('conda/meta.yaml.in') as f:
recipe=f.read()

recipe=re.sub("__VERSION__",__version__,recipe)

match=re.search("( *)(__REQUIRED__)",recipe)

requirements=""

for r in ast.literal_eval(str(_required_)):
requirements+=match.group(1)+"- " + r+"\n"

recipe=re.sub("( *)(__REQUIRED__)\n",requirements,recipe)

recipe=re.sub("__SUMMARY__",description(),recipe)

match=re.search("( *)(__DESCRIPTION__)",recipe)

description=""

for r in readme().split("\n"):
description+=match.group(1)+r+"\n"

recipe=re.sub("( *)(__DESCRIPTION__)",description,recipe)

with open('conda/meta.yaml',"w") as f:
f.write(recipe)

0 comments on commit 9c4adb6

Please sign in to comment.