DEV: conda build recipe and travis setup

This commit is contained in:
Christian Fernandez 2020-05-25 19:45:01 +02:00
parent 3f65d52466
commit 0a6c19efdb
3 changed files with 152 additions and 0 deletions

39
.travis.yml Normal file
View File

@ -0,0 +1,39 @@
language: python
python:
- "3.7" # we built a noarch (so in principle any recent version of python work)
# limit git clone depth to 10 commits
git:
depth: 10
install:
- sudo apt-get update
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda config --add channels conda-forge
- conda config --add channels spectrocat
- conda config --set channel_priority strict
script:
- conda create -n py38 python=3.8 pytest numpy scipy
- conda activate py38
- pip install .
- pytest
- conda create -n py36 python=3.6 pytest numpy scipy
- conda activate py36
- pip install .
- pytest
- conda create -n py37 python=3.7 pytest numpy scipy
- conda activate py37
- pip install .
- pytest
after_success:
- conda activate py37
- conda install conda-build anaconda-client
- bash recipe/conda_upload.sh

63
recipe/conda_upload.sh Normal file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env bash
## adapted on https://gist.github.com/zshaheen/fe76d1507839ed6fbfbccef6b9c13ed9
PKG_NAME=brukeropusreader
ANACONDA_USER=spectrocat
OS=noarch ## OS=$TRAVIS_OS_NAME-64
conda config --set anaconda_upload no
## TAG
TAG=$(git describe --tags)
IFS=$"-"
read -ra arr <<< "$TAG"
LAST_TAG="${arr[0]}"
IFS=$"."
read -ra tag <<< "$LAST_TAG"
NEXT_TAG="${tag[0]}.${tag[1]}.`expr ${tag[2]} + 1`"
NUMBER="${arr[1]}"
export CONDA_BLD_PATH="$HOME/conda-bld"
mkdir -p "$CONDA_BLD_PATH"
## Here we will choose depending on the way this script is run
if [[ $user != "travis" ]]; then
## if we are in local
TRAVIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $TRAVIS_BRANCH == $LAST_TAG ]]; then
TRAVIS_TAG=$LAST_TAG
fi
## else this run by TravisCI (this are env variables)
fi
echo "user: $USER current branch: $TRAVIS_BRANCH "
if [[ $TRAVIS_BRANCH == "master" ]]; then
## we build the current master repository (i.e.the last development version)
export DEVSTRING="dev"
export VERSION="$NEXT_TAG"
echo "***************************************************************************************************************"
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
echo "***************************************************************************************************************"
##conda build .
echo "***************************************************************************************************************"
echo "--> UPLOADING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2 to <dev> anaconda repository"
echo "***************************************************************************************************************"
##anaconda -t "$CONDA_UPLOAD_TOKEN" upload --force -u $ANACONDA_USER -l dev "$CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
fi
if [[ $TRAVIS_BRANCH == $TRAVIS_TAG ]]; then
## this is a "stable" release
export DEVSTRING="stable"
export VERSION="$LAST_TAG"
echo "***************************************************************************************************************"
echo "--> BUILDING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
echo "***************************************************************************************************************"
##conda build .
echo "***************************************************************************************************************"
echo "--> UPLOADING $CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2 to <main> anaconda repository"
echo "***************************************************************************************************************"
##anaconda -t "$CONDA_UPLOAD_TOKEN" upload --force -u $ANACONDA_USER "$CONDA_BLD_PATH/$OS/$PKG_NAME-$VERSION-$DEVSTRING.tar.bz2"
fi
exit $?

50
recipe/meta.yaml Normal file
View File

@ -0,0 +1,50 @@
{% set name = "brukeropusreader" %}
{% set version = environ['VERSION'] %}
package:
name: "{{ name|lower }}"
version: "{{ version }}"
source:
path: ../
build:
script_env:
- VERSION
- CONDA_BLD_PATH
string: {{ environ['DEVSTRING'] }}
noarch: python
script: "{{ PYTHON }} -m pip install . -vv"
requirements:
build:
- {{ compiler('cxx') }}
- python
host:
- python
- numpy
- pip
- scipy
run:
- python
- numpy
- scipy
test:
- python {{ python }}
test:
script_env:
- VERSION
- CONDA_BLD_PATH
imports:
- brukeropusreader
about:
home: "https://github.com/qedsoftware/brukeropusreader"
license: GPLv3
license_family: GPL3
summary: "Bruker OPUS File Reader"
extra:
recipe-maintainers:
- fernandezc