From 0a6c19efdbf4058f191bdb06a6ba84cdb6f25034 Mon Sep 17 00:00:00 2001 From: Christian Fernandez Date: Mon, 25 May 2020 19:45:01 +0200 Subject: [PATCH] DEV: conda build recipe and travis setup --- .travis.yml | 39 ++++++++++++++++++++++++++ recipe/conda_upload.sh | 63 ++++++++++++++++++++++++++++++++++++++++++ recipe/meta.yaml | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 .travis.yml create mode 100644 recipe/conda_upload.sh create mode 100644 recipe/meta.yaml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..178d4f0 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/recipe/conda_upload.sh b/recipe/conda_upload.sh new file mode 100644 index 0000000..aac8678 --- /dev/null +++ b/recipe/conda_upload.sh @@ -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 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
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 $? \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml new file mode 100644 index 0000000..24e9b86 --- /dev/null +++ b/recipe/meta.yaml @@ -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