From 3feb1384aed340faecdd538962bdf4710d19b336 Mon Sep 17 00:00:00 2001 From: Fabio Zanini Date: Sun, 5 Apr 2020 19:05:51 +1000 Subject: [PATCH] OSX in conda environments --- .travis.yml | 75 +++++++++++++++++++-------------------- .travis_before_install.sh | 35 ++++-------------- .travis_deploy.sh | 10 ++++-- .travis_install.sh | 2 ++ .travis_test.sh | 4 ++- setup.py | 26 ++++---------- 6 files changed, 63 insertions(+), 89 deletions(-) diff --git a/.travis.yml b/.travis.yml index e12fc18..db6bd94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,44 +12,43 @@ env: matrix: include: - # FIXME: focus on mojave - # - env: DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 - # python: 3.6 - # os: linux - # dist: trusty - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam' - # python: 2.7 - # os: linux - # dist: trusty - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam' - # python: 3.5 - # os: linux - # dist: trusty - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam' - # python: 3.6 - # os: linux - # dist: trusty - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam' - # python: 3.7 - # os: linux - # dist: bionic - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam' - # python: 3.8 - # os: linux - # dist: bionic - # sudo: required - # - env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' PYTHON_VERSION='2.7' - # language: generic - # os: osx - # - env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' PYTHON_VERSION='3.6' - # language: generic - # os: osx - - env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' PYTHON_VERSION='3.6' + #- env: DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 + # python: 3.6 + # os: linux + # dist: trusty + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam' + # python: 2.7 + # os: linux + # dist: trusty + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam' + # python: 3.5 + # os: linux + # dist: trusty + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam' + # python: 3.6 + # os: linux + # dist: trusty + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam' + # python: 3.7 + # os: linux + # dist: bionic + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam' + # python: 3.8 + # os: linux + # dist: bionic + # sudo: required + #- env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' CONDA_PY='2.7' + # language: generic + # os: osx + #- env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' CONDA_PY='3.6' + # language: generic + # os: osx + - env: CC=gcc PYSAM_VERSION='pysam>=0.13.0' CONDA_PY='3.8' language: generic os: osx osx_image: xcode11 diff --git a/.travis_before_install.sh b/.travis_before_install.sh index de4c9c3..4df1bcc 100755 --- a/.travis_before_install.sh +++ b/.travis_before_install.sh @@ -9,42 +9,19 @@ elif [ $TRAVIS_OS_NAME == 'osx' ]; then echo "Find out OSX version" osx_version=$(sw_vers -productVersion) echo "OSX version: $osx_version" - osx_version1=$(echo $osx_version | cut -d. -f1) - osx_version2=$(echo $osx_version | cut -d. -f2) - if [ $osx_version1 == "10" ] && [ $osx_version2 -ge 14 ]; then - #echo "Installing C headers for OSX Mojave and later" - #open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg - #sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_$osx_version1.$osx_version2.pkg -target / - echo "Find C++ libraries:" - ls /usr/X11R6 - ls /usr/X11R6/lib - echo "Find C headers for OSX Mojave and later" - ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ - echo "Result of scrun --show-sdk-path:" - xcrun --show-sdk-path - echo "Check the C++ header path:" - ls /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ - fi echo "Installing deps for OSX" - if [ $PYTHON_VERSION == "2.7" ]; then - CONDA_VER='2' - CONDA_URL="https://repo.continuum.io/miniconda/Miniconda${CONDA_VER}-latest-MacOSX-x86_64.sh" - elif [ $PYTHON_VERSION == "3.7" ]; then - CONDA_VER='3' - CONDA_URL="https://repo.continuum.io/miniconda/Miniconda${CONDA_VER}-latest-MacOSX-x86_64.sh" - # NOTE: Miniconda stopped supporting 3.6, but pysam is late... - elif [ $PYTHON_VERSION == "3.6" ]; then - CONDA_VER='3' - CONDA_URL='https://repo.continuum.io/miniconda/Miniconda3-4.5.4-MacOSX-x86_64.sh' - else - echo "OSX install with conda currently supports 2.7, 3.6, and 3.7" - fi + CONDA_URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" curl "${CONDA_URL}" -o "miniconda.sh" bash "miniconda.sh" -b -p $HOME/miniconda echo "$PATH" export PATH="$HOME/miniconda/bin:$PATH" source $HOME/miniconda/bin/activate + + # Make conda environment and activate + conda create -n travis python=$CONDA_PY + conda activate travis + # Use pip from conda conda install -y pip pip --version diff --git a/.travis_deploy.sh b/.travis_deploy.sh index 07ab03f..23aa39b 100755 --- a/.travis_deploy.sh +++ b/.travis_deploy.sh @@ -55,12 +55,18 @@ elif [ $TRAVIS_OS_NAME == 'osx' ]; then echo "TWINE_PASSWORD=$TWINE_PASSWORD" export PATH="$HOME/miniconda/bin:$PATH" source $HOME/miniconda/bin/activate + conda activate travis + pip --version pip install twine - if [ $PYTHON_VERSION == '2.7' ]; then + if [ $CONDA_PY == '2.7' ]; then PYARCH='cp27-cp27m' - elif [ $PYTHON_VERSION == '3.6' ]; then + elif [ $CONDA_PY == '3.6' ]; then PYARCH='cp36-cp36m' + elif [ $CONDA_PY == '3.7' ]; then + PYARCH='cp37-cp37m' + elif [ $CONDA_PY == '3.8' ]; then + PYARCH='cp38-cp38m' else echo "Python version not recognized" exit 1 diff --git a/.travis_install.sh b/.travis_install.sh index 4870469..2b4ec62 100755 --- a/.travis_install.sh +++ b/.travis_install.sh @@ -15,6 +15,8 @@ else if [ $TRAVIS_OS_NAME == 'osx' ]; then export PATH="$HOME/miniconda/bin:$PATH" source $HOME/miniconda/bin/activate + conda activate travis + # Somehow we need this to execute the setup.py at all... pip install numpy pip install $PYSAM_VERSION diff --git a/.travis_test.sh b/.travis_test.sh index 4518c53..9edb364 100755 --- a/.travis_test.sh +++ b/.travis_test.sh @@ -8,7 +8,9 @@ fi if [ "$TRAVIS_OS_NAME" == 'osx' ]; then export PATH="$HOME/miniconda/bin:$PATH" source $HOME/miniconda/bin/activate - PYTHON="$HOME/miniconda/bin/python$PYTHON_VERSION" + conda activate travis + #PYTHON="$HOME/miniconda/bin/python$CONDA_PY" + PYTHON=$(which python) else PYTHON=${PYTHON:-python} fi diff --git a/setup.py b/setup.py index 8229b45..2c20726 100644 --- a/setup.py +++ b/setup.py @@ -106,23 +106,12 @@ def get_include_dirs(cpp=False): return include_dirs -def get_library_dirs(cpp=False): +def get_library_dirs_cpp(): '''OSX 10.14 and later messed up C/C++ library locations''' - library_dirs = [] - paths = { - 'C': [], - 'C++': ['/usr/X11R6/lib'], - } - - for path in paths['C']: - if os.path.isdir(path): - library_dirs.append(path) - if cpp: - for path in paths['C++']: - if os.path.isdir(path): - library_dirs.append(path) - - return library_dirs + if sys.platform == 'darwin': + return ['/usr/X11R6/lib'] + else: + return [] def get_extra_args_cpp(): @@ -207,7 +196,7 @@ def run(self): setup(name='HTSeq', version=version, - author='Simon Anders', + author='Simon Anders, Fabio Zanini', author_email='sanders@fs.tum.de', maintainer='Fabio Zanini', maintainer_email='fabio.zanini@stanford.edu', @@ -236,13 +225,12 @@ def run(self): 'HTSeq._HTSeq', ['src/_HTSeq.c'], include_dirs=[numpy_include_dir]+get_include_dirs(), - library_dirs=get_library_dirs(), extra_compile_args=['-w']), Extension( 'HTSeq._StepVector', ['src/StepVector_wrap.cxx'], include_dirs=get_include_dirs(cpp=True), - library_dirs=get_library_dirs(cpp=True), + library_dirs=get_library_dirs_cpp(), extra_compile_args=['-w'] + get_extra_args_cpp(), extra_link_args=get_extra_args_cpp(), ),