Skip to content

Commit

Permalink
When installing from source package, use the included .c files (fasta…
Browse files Browse the repository at this point in the history
…vro#157)

* When installing from source package, use the included .c files

* Undo accidental whitespace change

* Set FASTAVRO_USE_CYTHON in Windows builds

* Set FASTAVRO_USE_CYTHON=1 in Travis builds

* Add FASTAVRO_USE_CYTHON=1 to .travis_build_wheel.sh
  • Loading branch information
barrywhart authored and scottbelden committed Feb 8, 2018
1 parent 82ca905 commit b53954d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis_build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ TRAVIS_PYTHON_VERSION=$1
TRAVIS_PYTHON_VERSION=${TRAVIS_PYTHON_VERSION/.}

/opt/python/*${TRAVIS_PYTHON_VERSION}*m/bin/pip install cython
/opt/python/*${TRAVIS_PYTHON_VERSION}*m/bin/python setup.py bdist_wheel
FASTAVRO_USE_CYTHON=1 /opt/python/*${TRAVIS_PYTHON_VERSION}*m/bin/python setup.py bdist_wheel
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ build: off

test_script:
- "set PYTHONPATH=%cd%"
- "set FASTAVRO_USE_CYTHON=1"
- "%PYTHON%\\python.exe setup.py build_ext --inplace"
- "%PYTHON%\\python.exe -m pytest -v tests"

after_test:
# If tests are successful, create binary packages for the project.
- "set FASTAVRO_USE_CYTHON=1"
- "%PYTHON%\\python.exe setup.py bdist_wheel"
- ps: "ls dist"

Expand Down
2 changes: 1 addition & 1 deletion publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -e
set -x

make
python setup.py sdist
FASTAVRO_USE_CYTHON=1 python setup.py sdist

windows_wheels_url="https://ci.appveyor.com/project/scottbelden/fastavro"
if [ ! -f dist/fastavro-${ver}-cp27-cp27m-win_amd64.whl ]; then
Expand Down
2 changes: 1 addition & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ flake8 --config=.flake8.cython fastavro
check-manifest

# Build Cython modules
python setup.py build_ext --inplace
FASTAVRO_USE_CYTHON=1 python setup.py build_ext --inplace

PYTHONPATH=${PWD} python -m pytest -v $@ tests
22 changes: 17 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ast
import os
import re
import sys

Expand All @@ -9,15 +10,23 @@

from setuptools import Extension

# publish.sh should set this variable to 1.
try:
USE_CYTHON = int(os.getenv('FASTAVRO_USE_CYTHON'))
except TypeError:
USE_CYTHON = False

ext = '.pyx' if USE_CYTHON else '.c'

# See http://setuptools.readthedocs.io/en/latest/setuptools.html\
# #distributing-extensions-compiled-with-pyrex
ext_modules = []
if not hasattr(sys, 'pypy_version_info'):
ext_modules += [
Extension('fastavro._read', ["fastavro/_read.pyx"]),
Extension('fastavro._schema', ["fastavro/_schema.pyx"]),
Extension('fastavro._six', ["fastavro/_six.pyx"]),
Extension('fastavro._write', ["fastavro/_write.pyx"]),
Extension('fastavro._read', ["fastavro/_read" + ext]),
Extension('fastavro._schema', ["fastavro/_schema" + ext]),
Extension('fastavro._six', ["fastavro/_six" + ext]),
Extension('fastavro._write', ["fastavro/_write" + ext]),
]


Expand All @@ -41,8 +50,11 @@ def version():
cpython_requires = [
# Setuptools 18.0 properly handles Cython extensions.
'setuptools>=18.0',
'Cython',
]
if USE_CYTHON:
cpython_requires += [
'Cython',
]
install_requires += cpython_requires
setup_requires += cpython_requires

Expand Down

0 comments on commit b53954d

Please sign in to comment.