Skip to content

Commit 0a7e7f0

Browse files
committed
Use tox to build wheels
1 parent 50c27a1 commit 0a7e7f0

8 files changed

+73
-47
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
os: osx
22
language: generic
3-
osx_image: beta-xcode6.2 # OS X 10.9
43
env:
54
- VERSION=2.7
65
- VERSION=3.3

appveyor.yml

+12-40
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,28 @@ version: '{branch}-{build}'
22
cache:
33
- '%LOCALAPPDATA%\pip\Cache'
44
environment:
5+
PYTHON: C:\Python35
56
password:
67
secure: pp1j5lAB9NN8ZDasgY+oxoGrNw0+4gGzbNZmHVwJkCzUyrNBP5ZIuCrwjmx4q6ifg7RMiE3bVt9MljFCJh3XpsvVOAcx+AGKsHSjtXd40HM=
7-
8-
matrix:
9-
- PYTHON: "C:\\Python26"
10-
PYTHON_ARCH: "32"
11-
12-
- PYTHON: "C:\\Python26-x64"
13-
PYTHON_ARCH: "64"
14-
15-
- PYTHON: "C:\\Python27"
16-
PYTHON_ARCH: "32"
17-
18-
- PYTHON: "C:\\Python27-x64"
19-
PYTHON_ARCH: "64"
20-
21-
- PYTHON: "C:\\Python33"
22-
PYTHON_ARCH: "32"
23-
24-
- PYTHON: "C:\\Python33-x64"
25-
PYTHON_ARCH: "64"
26-
27-
- PYTHON: "C:\\Python34"
28-
PYTHON_ARCH: "32"
29-
30-
- PYTHON: "C:\\Python34-x64"
31-
PYTHON_ARCH: "64"
32-
33-
- PYTHON: "C:\\Python35"
34-
PYTHON_ARCH: "32"
35-
36-
- PYTHON: "C:\\Python35-x64"
37-
PYTHON_ARCH: "64"
38-
8+
cache:
9+
- '%LOCALAPPDATA%\pip\Cache'
3910
init:
40-
- "ECHO Python %PYTHON%"
11+
- ps: "ls C:/Python*"
4112

4213
install:
43-
- "SET PATH=%PYTHON%;%PYTHON%\\scripts;%PATH%"
14+
- choco install python.pypy > pypy-inst.log 2>&1 || (type pypy-inst.log & exit /b 1)
15+
- "SET PATH=C:\tools\pypy\pypy;%PYTHON%;%PYTHON%\\scripts;%PATH%"
16+
- pip install tox
4417
- echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
4518
- "pip install -r dev-requirements.txt"
4619

47-
build_script:
48-
- "cython bencoder.pyx"
49-
- "python setup.py install"
20+
build: off
5021

5122
test_script:
52-
- "del bencoder.c"
53-
- "python setup.py test"
23+
- tox
5424

5525
on_success:
26+
- tox -c tox-wheels.ini
5627
- pip install codecov
5728
- codecov
5829

@@ -64,6 +35,7 @@ deploy_script:
6435
- echo username=whtsky >> %USERPROFILE%\\.pypirc
6536
- echo password=%password% >> %USERPROFILE%\\.pypirc
6637
- set HOME=%USERPROFILE%
67-
- ps: if($env:APPVEYOR_REPO_TAG -eq $TRUE) { "python -W ignore setup.py bdist_wheel upload" }
38+
- pip install twine
39+
- ps: if($env:APPVEYOR_REPO_TAG -eq $TRUE) { "twine upload wheelhouse/bencoder*.whl" }
6840

6941
deploy : on

ci/build-wheels.sh

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ cd /io
77
for PYBIN in /opt/python/*/bin/; do
88
${PYBIN}/pip install -r /io/dev-requirements.txt
99
${PYBIN}/python setup.py test
10+
pwd
11+
ls
1012
rm *.so
1113
done
1214

pytest-nocov.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
testpaths = tests
3+
addopts = -rw

release.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22
cython bencoder.pyx
3-
python setup.py sdist --formats=zip,gztar bdist_wheel register
3+
python setup.py sdist --formats=zip,gztar register
4+
tox -c tox-wheels.ini
45
twine upload dist/*

setup.py

+38-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
install_requires.append('ordereddict>=1.1')
1212

1313
base_path = os.path.dirname(os.path.abspath(__file__))
14+
pyx_path = os.path.join(base_path, 'bencoder.pyx')
15+
c_path = os.path.join(base_path, 'bencoder.c')
1416

15-
if sys.argv[-1] == 'test':
17+
if sys.argv[-1] == 'test' and platform.python_implementation() == 'CPython':
1618
from Cython.Compiler.Options import directive_defaults
1719

1820
directive_defaults['linetrace'] = True
@@ -21,14 +23,45 @@
2123
from Cython.Build import cythonize
2224
ext_modules = cythonize(Extension(
2325
"bencoder",
24-
["bencoder.pyx"],
26+
[pyx_path],
2527
define_macros=[('CYTHON_TRACE', '1')]
2628
))
27-
else:
29+
elif os.path.exists(c_path):
2830
ext_modules = [Extension(
2931
'bencoder',
30-
[os.path.join(base_path, 'bencoder.c')]
32+
[c_path]
3133
)]
34+
else:
35+
from Cython.Build import cythonize
36+
ext_modules = cythonize(Extension(
37+
"bencoder",
38+
[pyx_path]
39+
))
40+
41+
42+
# patch bdist_wheel
43+
cmdclass = {}
44+
try:
45+
from wheel.bdist_wheel import bdist_wheel
46+
47+
REPLACE = (
48+
'macosx_10_6_intel.'
49+
'macosx_10_9_intel.'
50+
'macosx_10_9_x86_64.'
51+
'macosx_10_10_intel.'
52+
'macosx_10_10_x86_64'
53+
)
54+
55+
class _bdist_wheel(bdist_wheel):
56+
def get_tag(self):
57+
tag = bdist_wheel.get_tag(self)
58+
if tag[2] == 'macosx_10_6_intel':
59+
tag = (tag[0], tag[1], REPLACE)
60+
return tag
61+
62+
cmdclass['bdist_wheel'] = _bdist_wheel
63+
except ImportError:
64+
pass
3265

3366

3467
setup(
@@ -44,6 +77,7 @@
4477
zip_safe=False,
4578
include_package_data=True,
4679
keywords=['bencoding', 'encode', 'decode', 'bittorrent', 'bencode', 'bencoder', 'cython'],
80+
cmdclass=cmdclass,
4781
classifiers=[
4882
'Environment :: Other Environment',
4983
'Intended Audience :: Developers',

tox-wheels.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[tox]
2+
envlist = py26, py27, py33, py34, py35, pypy
3+
4+
[testenv]
5+
commands = pip wheel {toxinidir} -w {toxinidir}/wheelhouse/
6+
skip_install = True
7+
deps =
8+
cython

tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ envlist = py26, py27, py33, py34, py35, pypy
55
commands = python setup.py test
66
skip_install = True
77
deps =
8-
cython
8+
cython
9+
10+
[testenv:pypy]
11+
skip_install = False
12+
deps =
13+
cython
14+
pytest
15+
commands = py.test -c pytest-nocov.ini

0 commit comments

Comments
 (0)