From 7359052467d5a7fdc013929df0f157c7277ebcfd Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Sat, 19 Apr 2014 13:24:09 -0500 Subject: [PATCH] Only build extensions against known good releases --- README.rst | 3 +++ setup.py | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index a0026e0..e19a7ad 100644 --- a/README.rst +++ b/README.rst @@ -23,6 +23,9 @@ Or with the standard Python distutils incantation: :: python setup.py build python setup.py install +The C extension will be built for supported python versions. If you do not +want the C extension, set the environment variable ``RADIX_NO_EXT=1``. + Tests are in the ``tests/`` directory and can be run with ``python setup.py test``. diff --git a/setup.py b/setup.py index 51146e5..4c8aa09 100755 --- a/setup.py +++ b/setup.py @@ -2,12 +2,19 @@ import codecs import re +import sys +import os from setuptools import setup, find_packages, Extension from os.path import abspath, dirname, join here = abspath(dirname(__file__)) +# determine the python version +IS_PYPY = hasattr(sys, 'pypy_version_info') +IS_PY3K = (sys.version_info.major == 3) +RADIX_NO_EXT = os.environ.get('RADIX_NO_EXT', False) + # Read the version number from a source file. def find_version(*file_paths): @@ -28,8 +35,12 @@ def find_version(*file_paths): with codecs.open(join(here, 'README.rst'), encoding='utf-8') as f: README = f.read() -sources = ['radix/_radix.c', 'radix/_radix/radix.c'] -radix = Extension('radix._radix', sources=sources) +# introduce some extra setup_args if Python 2.x +extra_kwargs = {} +if not IS_PYPY and not IS_PY3K and not RADIX_NO_EXT: + sources = ['radix/_radix.c', 'radix/_radix/radix.c'] + radix = Extension('radix._radix', sources=sources) + extra_kwargs['ext_modules'] = [radix] setup( @@ -53,6 +64,6 @@ def find_version(*file_paths): ], setup_requires=['nose', 'coverage'], packages=find_packages(exclude=['tests', 'tests.*']), - ext_modules=[radix], test_suite='nose.collector', + **extra_kwargs )