8000 Merge pull request #14 from dean0x7d/tests · PaulEcoffet/python_example@7ad3847 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ad3847

Browse files
authored
Merge pull request pybind#14 from dean0x7d/tests
Configure tests on Travis and AppVeyor
2 parents 28381e3 + acb5f7d commit 7ad3847

File tree

6 files changed

+110
-3
lines changed

6 files changed

+110
-3
lines changed

.appveyor.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '{build}'
2+
image: Visual Studio 2015
3+
platform:
4+
- x86
5+
- x64
6+
environment:
7+
global:
8+
DISTUTILS_USE_SDK: 1
9+
MSSdk: 1
10+
matrix:
11+
- PYTHON: 27
12+
- PYTHON: 35
13+
- CONDA: 27
14+
- CONDA: 35
15+
matrix:
16+
allow_failures:
17+
- platform: x86
18+
CONDA: 27
19+
install:
20+
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'
21+
- ps: |
22+
if ($env:PYTHON) {
23+
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
24+
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
25+
pip install --disable-pip-version-check --user --upgrade pip
26+
} elseif ($env:CONDA) {
27+
if ($env:CONDA -eq "27") { $env:CONDA = "" }
28+
if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" }
29+
$env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH"
30+
conda config --set always_yes yes --set changeps1 no
31+
conda config --add channels conda-forge
32+
conda update -q conda
33+
conda install -q conda-build
34+
}
35+
build_script:
36+
- ps: |
37+
if ($env:PYTHON) {
38+
python setup.py sdist
39+
pip install --verbose dist\python_example-0.0.1.zip
40+
} elseif ($env:CONDA) {
41+
conda build conda.recipe
42+
conda install --use-local python_example
43+
}
44+
test_script:
45+
- ps: python tests\test.py

.travis.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
language: cpp
2+
os:
3+
- linux
4+
- osx
5+
env:
6+
- PYTHON=2.7
7+
- PYTHON=3.5
8+
- CONDA=2.7
9+
- CONDA=3.5
10+
addons:
11+
apt:
12+
sources:
13+
- ubuntu-toolchain-r-test
14+
- deadsnakes
15+
packages:
16+
- g++-4.8
17+
- python3.5
18+
- python3.5-dev
19+
before_install:
20+
- |
21+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi
22+
if [ -n "$PYTHON" ]; then
23+
if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON" = "3.5" ]; then
24+
brew update; brew install python3;
25+
fi
26+
pip install --user --upgrade pip virtualenv
27+
virtualenv -p python$PYTHON venv
28+
source venv/bin/activate
29+
elif [ -n "$CONDA" ]; then
30+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi
31+
wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh
32+
bash miniconda.sh -b -p $HOME/miniconda
33+
export PATH="$HOME/miniconda/bin:$PATH"
34+
conda config --set always_yes yes --set changeps1 no
35+
conda config --add channels conda-forge
36+
conda update -q conda
37+
conda install -q conda-build
38+
conda create -q -n test-environment python=$CONDA
39+
source activate test-environment
40+
fi
41+
install:
42+
- |
43+
if [ -n "$PYTHON" ]; then
44+
python setup.py sdist
45+
pip install --verbose dist/*.tar.gz
46+
elif [ -n "$CONDA" ]; then
47+
conda build conda.recipe
48+
conda install --use-local python_example
49+
fi
50+
script:
51+
- python tests/test.py

conda.recipe/bld.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
1+
if "%ARCH%" == "32" (set PLATFORM=x86) else (set PLATFORM=x64)
2+
call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%
23
set DISTUTILS_USE_SDK=1
34
set MSSdk=1
45
"%PYTHON%" setup.py install

conda.recipe/meta.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package:
22
name: python_example
3-
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
3+
version: {{ environ.get('GIT_DESCRIBE_TAG', 'dev') }}
44

55
build:
66
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
77
{% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0
88
{% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %}
9+
script_env:
10+
- CC
11+
- CXX
912

1013
source:
1114
git_url: ../

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ class BuildExt(build_ext):
7878
def build_extensions(self):
7979
ct = self.compiler.compiler_type
8080
opts = self.c_opts.get(ct, [])
81-
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
8281
if ct == 'unix':
82+
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
8383
opts.append(cpp_flag(self.compiler))
8484
if has_flag(self.compiler, '-fvisibility=hidden'):
8585
opts.append('-fvisibility=hidden')
86+
elif ct == 'msvc':
87+
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
8688
for ext in self.extensions:
8789
ext.extra_compile_args = opts
8890
build_ext.build_extensions(self)

tests/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import python_example as m
2+
3+
assert m.__version__ == '0.0.1'
4+
assert m.add(1, 2) == 3
5+
assert m.subtract(1, 2) == -1

0 commit comments

Comments
 (0)
0