Skip to content

Commit

Permalink
OSX in conda environments
Browse files Browse the repository at this point in the history
  • Loading branch information
iosonofabio committed Apr 5, 2020
1 parent d701780 commit 3feb138
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 89 deletions.
75 changes: 37 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 6 additions & 29 deletions .travis_before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions .travis_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .travis_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 7 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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(),
),
Expand Down

0 comments on commit 3feb138

Please sign in to comment.