summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-22 17:31:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-22 17:31:50 -0400
commitec97911ed915238b4ea1ce51d6f7a77d49790f2b (patch)
treeada9947f79f133b1b526d2ef60c24ca1660945dd /setup.py
parentc464960fddf0c3d2db3acff9f772b057e32bcf67 (diff)
downloadsqlalchemy-ec97911ed915238b4ea1ce51d6f7a77d49790f2b.tar.gz
- Adjusted ``setup.py`` file to support the possible future
removal of the ``setuptools.Feature`` extension from setuptools. If this keyword isn't present, the setup will still succeed with setuptools rather than falling back to distutils. C extension building can be disabled now also by setting the DISABLE_SQLALCHEMY_CEXT environment variable. This variable works whether or not setuptools is even available. fixes #2986 - using platform.python_implementation() in setup.py to detect CPython. I've tested this function on OSX and linux on Python 2.6 through 3.4, including 3.1, 3.2, 3.3. Unfortunately, on OSX + 3.2 only, it seems to segfault. I've tried installing 3.2.5 from the python.org .dmg, building it from source, and also blew away the whole 3.2 directory, something seems to be wrong with the "platform" module on that platform only, and there's also no issue on bugs.python.org; however, I'm going with it anyway. If someone is using 3.2 on OSX they really should be upgrading.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py40
1 files changed, 31 insertions, 9 deletions
diff --git a/setup.py b/setup.py
index f682081df..298dc8bb4 100644
--- a/setup.py
+++ b/setup.py
@@ -10,18 +10,33 @@ import sys
from distutils.command.build_ext import build_ext
from distutils.errors import (CCompilerError, DistutilsExecError,
DistutilsPlatformError)
+
+has_feature = False
try:
- from setuptools import setup, Extension, Feature
- has_setuptools = True
+ from setuptools import setup, Extension
+ try:
+ # see
+ # https://bitbucket.org/pypa/setuptools/issue/65/deprecate-and-remove-features,
+ # where they may remove Feature.
+ from setuptools import Feature
+ has_feature = True
+ except ImportError:
+ pass
except ImportError:
- has_setuptools = False
from distutils.core import setup, Extension
- Feature = None
-cmdclass = {}
-pypy = hasattr(sys, 'pypy_version_info')
-jython = sys.platform.startswith('java')
+try:
+ import platform
+except ImportError:
+ pypy = hasattr(sys, 'pypy_version_info')
+ jython = sys.platform.startswith('java')
+ cpython = not pypy and not jython
+else:
+ cpython = platform.python_implementation() == 'CPython'
+
py3k = False
+
+cmdclass = {}
extra = {}
if sys.version_info < (2, 6):
raise Exception("SQLAlchemy requires Python 2.6 or higher.")
@@ -100,7 +115,7 @@ r_file.close()
def run_setup(with_cext):
kwargs = extra.copy()
if with_cext:
- if Feature:
+ if has_feature:
kwargs['features'] = {'cextensions': Feature(
"optional C speed-enhancements",
standard=True,
@@ -137,13 +152,20 @@ def run_setup(with_cext):
**kwargs
)
-if pypy or jython:
+if not cpython:
run_setup(False)
status_msgs(
"WARNING: C extensions are not supported on " +
"this Python platform, speedups are not enabled.",
"Plain-Python build succeeded."
)
+elif os.environ.get('DISABLE_SQLALCHEMY_CEXT'):
+ run_setup(False)
+ status_msgs(
+ "DISABLE_SQLALCHEMY_CEXT is set; not attempting to build C extensions.",
+ "Plain-Python build succeeded."
+ )
+
else:
try:
run_setup(True)