Skip to content

Commit

Permalink
Merge pull request #5 from ilastik/add-auto-deploy
Browse files Browse the repository at this point in the history
add automatic deploy via ci
  • Loading branch information
k-dominik authored Nov 17, 2023
2 parents 57c1cf7 + a9994b4 commit f805b83
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 70 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: deploy

on:
push:
tags:
- '1.*'

jobs:
package:
strategy:
runs-on: ubuntu-latest
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install xvfb/deps
run: |
sudo apt-get update
sudo apt-get install -yy mesa-utils libgl1-mesa-dev xvfb curl
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: true
activate-environment: bld-env
environment-file: .github/workflows/etc/bld-environment.yml
condarc-file: .github/workflows/etc/conda-rc-deploy.yml
miniforge-variant: Miniforge3
use-mamba: true
- name: linux conda build
if: matrix.os == 'ubuntu-latest'
shell: bash -l {0}
run: xvfb-run --server-args="-screen 0 1024x768x24" conda mambabuild -c conda-forge conda-recipe
9 changes: 9 additions & 0 deletions .github/workflows/etc/bld-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: bld-env
channels:
- conda-forge
- nodefaults
dependencies:
- anaconda-client
- conda-build
- setuptools_scm
- boa
1 change: 1 addition & 0 deletions .github/workflows/etc/conda-rc-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
anaconda_upload: True
9 changes: 5 additions & 4 deletions .github/workflows/test.yaml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -yy mesa-utils libgl1-mesa-dev xvfb curl
- name: setup conda
uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: true
activate-environment: ""
activate-environment: bld-env
environment-file: .github/workflows/etc/bld-environment.yml
miniforge-variant: Miniforge3
use-mamba: true
- name: linux conda build test
shell: bash -l {0}
run: |
conda install -n base -c conda-forge mamba boa -y
xvfb-run --server-args="-screen 0 1024x768x24" conda mambabuild --override-channels \
-c conda-forge conda-recipe
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ ilastikrag.egg-info
*.jpg
*.swp
*.ipynb_checkpoints

ilastikrag/_version.py
17 changes: 8 additions & 9 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{% set setup_py_data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}

package:
name: ilastikrag

{% if GIT_DESCRIBE_NUMBER|int == 0 %}
version: {{GIT_DESCRIBE_TAG}}
{% else %}
# If we're using a non-tagged revision, append '.postN' to the version
version: {{GIT_DESCRIBE_TAG}}.post{{GIT_DESCRIBE_NUMBER}}
{% endif %}
version: {{ setup_py_data.version }}

source:
path: ../

build:
noarch: python
number: 0
string: py_{{PKG_BUILDNUM}}_g{{GIT_FULL_HASH[:7]}}
script_env:
- SETUPTOOLS_SCM_PRETEND_VERSION={{ setup_py_data.version }}
script: python -m pip install --no-deps --ignore-installed .

requirements:
build:
host:
- python >=3.7
- pip
- setuptools >=40.0
- setuptools_scm
run:
- python >=3.7
# vigra/numpy incompatibility - related to indexing with a non-tuple sequence
Expand Down
5 changes: 3 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Create a development environment

```bash
conda env create --file dev/environment-dev.py
conda env create --file dev/environment-dev.yaml --name irag-dev
conda run --name irag-dev pip install -e .
```

This will create an environment with the name `ilastikrag-dev`, that can be activated with `conda activate ilastikrag-dev`.
This will create an environment with the name `irag-dev`, that can be activated with `conda activate irag-dev`.
3 changes: 2 additions & 1 deletion dev/environment-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: ilastikrag-dev
channels:
- conda-forge
dependencies:
- h5py
- networkx
- numpy>=1.12,<1.20
- pandas
- pip
- pytest
- python>=3.7
- setuptools_scm
- vigra
17 changes: 15 additions & 2 deletions ilastikrag/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
from __future__ import absolute_import
from .version import __version__
from . import accumulators
from .accumulators import BaseEdgeAccumulator
from .accumulators import BaseSpAccumulator
from .rag import Rag

try:
from ._version import version
except ModuleNotFoundError:
raise RuntimeError(
"Couldn't determine ilastik version - if you are developing ilastik please "
"make sure to use an editable install (`pip install -e .`). "
"Otherwise, please report this issue to the ilastik development team: team@ilastik.org"
)

##################
# # Version info ##
##################

__version__ = version
3 changes: 0 additions & 3 deletions ilastikrag/version.py

This file was deleted.

61 changes: 12 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,17 @@
#!/usr/bin/env python

import os
import subprocess
from setuptools import setup, find_packages
import setuptools_scm

def determine_version(default_version_file):
# If running in conda-build, read version from the environment.
if 'PKG_VERSION' in os.environ:
auto_version = os.environ['PKG_VERSION']
else:
# Try getting it from the latest git tag
try:
commit_details = subprocess.check_output("git describe --tags --long HEAD".split()).decode('utf-8')
last_tag, commits_since_tag = commit_details.split('-')[:2]
auto_version = last_tag
if int(commits_since_tag) > 0:
# Append commit count to version
# (BTW, the .post## convention is recognized by PEP440)
# For example: '0.2.post5'
auto_version = last_tag + '.post' + commits_since_tag
except subprocess.CalledProcessError:
# Weird: We're not in a git repo or conda-bld/work.
# Read the default value from the source code, I guess.
version_globals = {}
exec(compile(open(default_version_file).read(), default_version_file, 'exec'), version_globals)
auto_version = version_globals['__version__']
return auto_version
_version = setuptools_scm.get_version(write_to="ilastikrag/_version.py")

VERSION_FILE = 'ilastikrag/version.py'
auto_version = determine_version(VERSION_FILE)

# Cache version.py, then overwrite it with the auto-version
with open(VERSION_FILE, 'r') as f:
orig_version_contents = f.read()

with open(VERSION_FILE, 'w') as f:
f.write("__version__ = '{}'\n".format(auto_version))

try:
setup(name='ilastikrag',
version=auto_version,
description='ND Region Adjacency Graph with edge feature algorithms',
author='Stuart Berg',
author_email='bergs@janelia.hhmi.org',
url='github.com/stuarteberg/ilastikrag',
packages=find_packages()
## see conda-recipe/meta.yaml for dependency information
##install_requires=['numpy', 'h5py', 'pandas', 'vigra', 'networkx']
)
finally:
# Restore the version.py source as it was
with open(VERSION_FILE, 'w') as f:
f.write(orig_version_contents)
setup(name='ilastikrag',
version=_version,
description='ND Region Adjacency Graph with edge feature algorithms',
author='Stuart Berg',
author_email='bergs@janelia.hhmi.org',
url='github.com/stuarteberg/ilastikrag',
packages=find_packages()
## see conda-recipe/meta.yaml for dependency information
##install_requires=['numpy', 'h5py', 'pandas', 'vigra', 'networkx']
)

0 comments on commit f805b83

Please sign in to comment.