]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Adjusted ``setup.py`` file to support the possible future
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 22 Mar 2014 21:31:50 +0000 (17:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 22 Mar 2014 21:47:07 +0000 (17:47 -0400)
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.
- adjusted the logic for platform_implementation(), apparently "platform"
is there in python 2.5, so we are doing a version check.
Conflicts:
doc/build/intro.rst
setup.py

doc/build/changelog/changelog_08.rst
doc/build/intro.rst
setup.py

index 809b38950144927809edc122df6fa69185e58cf6..899be4d0eb0b25c2976f5168aa20f251771e5864 100644 (file)
 .. changelog::
     :version: 0.8.6
 
+    .. change::
+        :tags: bug, general
+        :tickets: 2986
+        :versions: 0.9.4
+
+        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.
+
     .. change::
         :tags: bug, ext
         :versions: 0.9.4
index c5e7f7425f40b0e481ea4a3e5735db3f1fa74596..b16e360ae10de01abee64cb8e7c8544a896d9e61 100644 (file)
@@ -93,11 +93,7 @@ SQLAlchemy supports installation using standard Python "distutils" or
   using the ``setup.py`` script. The C extensions as well as Python 3 builds are supported.
 * **Standard Setuptools** - When using `setuptools <http://pypi.python.org/pypi/setuptools/>`_,
   SQLAlchemy can be installed via ``setup.py`` or ``easy_install``, and the C
-  extensions are supported.  setuptools is not supported on Python 3 at the time
-  of this writing.
-* **Distribute** - With `distribute <http://pypi.python.org/pypi/distribute/>`_,
-  SQLAlchemy can be installed via ``setup.py`` or ``easy_install``, and the C
-  extensions as well as Python 3 builds are supported.
+  extensions are supported.
 * **pip** - `pip <http://pypi.python.org/pypi/pip/>`_ is an installer that
   rides on top of ``setuptools`` or ``distribute``, replacing the usage
   of ``easy_install``.  It is often preferred for its simpler mode of usage.
@@ -117,6 +113,11 @@ Or with pip::
 This command will download the latest version of SQLAlchemy from the `Python
 Cheese Shop <http://pypi.python.org/pypi/SQLAlchemy>`_ and install it to your system.
 
+.. note::
+
+    Beta releases of SQLAlchemy may not be present on Pypi, and may instead
+    require a direct download first.
+
 Installing using setup.py
 ----------------------------------
 
@@ -131,26 +132,38 @@ SQLAlchemy includes C extensions which provide an extra speed boost for
 dealing with result sets. Currently, the extensions are only supported on the
 2.xx series of cPython, not Python 3 or Pypy.
 
-setup.py will automatically build the extensions if an appropriate platform is
+``setup.py`` will automatically build the extensions if an appropriate platform is
 detected. If the build of the C extensions fails, due to missing compiler or
 other issue, the setup process will output a warning message, and re-run the
 build without the C extensions, upon completion reporting final status.
 
 To run the build/install without even attempting to compile the C extensions,
-pass the flag ``--without-cextensions`` to the ``setup.py`` script::
+the ``DISABLE_SQLALCHEMY_CEXT`` environment variable may be specified.  The
+use case for this is either for special testing circumstances, or in the rare
+case of compatibility/build issues not overcome by the usual "rebuild"
+mechanism::
 
-    python setup.py --without-cextensions install
+  # *** only in SQLAlchemy 0.9.4 / 0.8.6 or greater ***
+  export DISABLE_SQLALCHEMY_CEXT=1; python setup.py install
 
-Or with pip::
+.. versionadded:: 0.9.4,0.8.6  Support for disabling the build of
+   C extensions using the ``DISABLE_SQLALCHEMY_CEXT`` environment variable
+   has been added.  This allows control of C extension building whether or not
+   setuptools is available, and additionally works around the fact that
+   setuptools will possibly be **removing support** for command-line switches
+   such as ``--without-extensions`` in a future release.
 
-    pip install --global-option='--without-cextensions' SQLAlchemy
+   For versions of SQLAlchemy prior to 0.9.4 or 0.8.6, the
+   ``--without-cextensions`` option may be used to disable the attempt to build
+   C extensions, provided setupools is in use, and provided the ``Feature``
+   construct is supported by the installed version of setuptools::
 
-.. note::
+      python setup.py --without-cextensions install
+
+   Or with pip::
+
+      pip install --global-option='--without-cextensions' SQLAlchemy
 
-   The ``--without-cextensions`` flag is available **only** if ``setuptools``
-   or ``distribute`` is installed.  It is not available on a plain Python ``distutils``
-   installation.  The library will still install without the C extensions if they
-   cannot be built, however.
 
 Installing on Python 3
 ----------------------------------
index 0cdbb40d77c538e44431513e3a694018a0e83062..12431886ba9ba61f868b31c76143f098cfc4e233 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -10,11 +10,20 @@ import sys
 from distutils.command.build_ext import build_ext
 from distutils.errors import (CCompilerError, DistutilsExecError,
                               DistutilsPlatformError)
+
+has_feature = has_setuptools = False
 try:
-    from setuptools import setup, Extension, Feature
+    from setuptools import setup, Extension
     has_setuptools = True
+    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
     try:  # Python 3
@@ -22,10 +31,19 @@ except ImportError:
     except ImportError:  # Python 2
         from distutils.command.build_py import build_py
 
-cmdclass = {}
-pypy = hasattr(sys, 'pypy_version_info')
-jython = sys.platform.startswith('java')
+py25 = sys.version_info < (2, 6)
+
+if py25:
+    pypy = hasattr(sys, 'pypy_version_info')
+    jython = sys.platform.startswith('java')
+    cpython = not pypy and not jython
+else:
+    import platform
+    cpython = platform.python_implementation() == 'CPython'
+
 py3k = False
+
+cmdclass = {}
 extra = {}
 if sys.version_info < (2, 4):
     raise Exception("SQLAlchemy requires Python 2.4 or higher.")
@@ -111,7 +129,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,
@@ -160,7 +178,7 @@ def unmonkeypatch2to3():
     if hasattr(RefactoringTool, 'old_refactor_string'):
         RefactoringTool.refactor_string = RefactoringTool.old_refactor_string
 
-if pypy or jython or py3k:
+if not cpython or py3k:
     if py3k:
         # monkeypatch our preprocessor onto the 2to3 tool.
         monkeypatch2to3()
@@ -171,11 +189,19 @@ if pypy or jython or py3k:
             # unmonkeypatch to not stomp other setup.py's that are compiled
             # and exec'd and which also require 2to3 fixing
             unmonkeypatch2to3()
+
     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)