From b6d1cd61b55e84583fe3505a462e3852fee8d7bd Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 11 Jun 2016 00:16:24 +0200 Subject: [PATCH 1/5] Configure tests on Travis and AppVeyor --- .appveyor.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test.py | 5 +++++ 3 files changed, 101 insertions(+) create mode 100644 .appveyor.yml create mode 100644 .travis.yml create mode 100644 tests/test.py diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..6c2110b --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,45 @@ +version: '{build}' +image: Visual Studio 2015 +platform: +- x86 +- x64 +environment: + global: + DISTUTILS_USE_SDK: 1 + MSSdk: 1 + matrix: + - PYTHON: 27 + - PYTHON: 35 + - CONDA: 27 + - CONDA: 35 +matrix: + allow_failures: + - platform: x86 + CONDA: 27 +install: +- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%' +- ps: | + if ($env:PYTHON) { + if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } + $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" + pip install --disable-pip-version-check --user --upgrade pip + } elseif ($env:CONDA) { + if ($env:CONDA -eq "27") { $env:CONDA = "" } + if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" } + $env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH" + conda config --set always_yes yes --set changeps1 no + conda config --add channels conda-forge + conda update -q conda + conda install -q conda-build + } +build_script: +- ps: | + if ($env:PYTHON) { + python setup.py sdist + pip install --verbose dist\python_example-0.0.1.zip + } elseif ($env:CONDA) { + conda build conda.recipe + conda install --use-local python_example + } +test_script: +- ps: python tests\test.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fe5dd36 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,51 @@ +language: cpp +os: +- linux +- osx +env: +- PYTHON=2.7 +- PYTHON=3.5 +- CONDA=2.7 +- CONDA=3.5 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - deadsnakes + packages: + - g++-4.8 + - python3.5 + - python3.5-dev +before_install: +- | + if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi + if [ -n "$PYTHON" ]; then + if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON" = "3.5" ]; then + brew update; brew install python3; + fi + pip install --user --upgrade pip virtualenv + virtualenv -p python$PYTHON venv + source venv/bin/activate + elif [ -n "$CONDA" ]; then + if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi + wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + conda config --set always_yes yes --set changeps1 no + conda config --add channels conda-forge + conda update -q conda + conda install -q conda-build + conda create -q -n test-environment python=$CONDA + source activate test-environment + fi +install: +- | + if [ -n "$PYTHON" ]; then + python setup.py sdist + pip install --verbose dist/*.tar.gz + elif [ -n "$CONDA" ]; then + conda build conda.recipe + conda install --use-local python_example + fi +script: +- python tests/test.py diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..f877b62 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,5 @@ +import python_example as m + +assert m.__version__ == '0.0.1' +assert m.add(1, 2) == 3 +assert m.subtract(1, 2) == -1 From 22a3c2d10f342239f90908e5beba59928622a534 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 11 Jun 2016 01:03:43 +0200 Subject: [PATCH 2/5] Fix compiler error on Windows --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d4415eb..75392c9 100644 --- a/setup.py +++ b/setup.py @@ -78,11 +78,13 @@ class BuildExt(build_ext): def build_extensions(self): ct = self.compiler.compiler_type opts = self.c_opts.get(ct, []) - opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version()) if ct == 'unix': + opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version()) opts.append(cpp_flag(self.compiler)) if has_flag(self.compiler, '-fvisibility=hidden'): opts.append('-fvisibility=hidden') + elif ct == 'msvc': + opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) for ext in self.extensions: ext.extra_compile_args = opts build_ext.build_extensions(self) From 6f68152c784c809729ae40941e2dfb818fe17edf Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 11 Jun 2016 22:29:41 +0200 Subject: [PATCH 3/5] Fix conda "empty version" error --- conda.recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index ae0a2db..1b999c5 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -1,6 +1,6 @@ package: name: python_example - version: {{ environ.get('GIT_DESCRIBE_TAG', '') }} + version: {{ environ.get('GIT_DESCRIBE_TAG', 'dev') }} build: number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} From 516d265bfac2b2d4ae09469615d16ea942604730 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 11 Jun 2016 22:30:55 +0200 Subject: [PATCH 4/5] Propagate active compiler to conda-build Without this, conda-build selects Travis's outdated C++98 compiler which can't build pybind11. --- conda.recipe/meta.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 1b999c5..a62d2eb 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -6,6 +6,9 @@ build: number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} {% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0 {% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %} + script_env: + - CC + - CXX source: git_url: ../ From acb5f7d1ba69b3c93ba869f2ad70468c8a739323 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 11 Jun 2016 21:13:47 +0200 Subject: [PATCH 5/5] Fix conda build on 32-bit Windows --- conda.recipe/bld.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda.recipe/bld.bat b/conda.recipe/bld.bat index 5ddc156..1e575cb 100644 --- a/conda.recipe/bld.bat +++ b/conda.recipe/bld.bat @@ -1,4 +1,5 @@ -call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64 +if "%ARCH%" == "32" (set PLATFORM=x86) else (set PLATFORM=x64) +call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM% set DISTUTILS_USE_SDK=1 set MSSdk=1 "%PYTHON%" setup.py install