Please carefully review the sections on behavioral changes for
potentially backwards-incompatible changes in behavior.
-Platform Changes
-================
+Platform / Installer Changes
+============================
+
+Setuptools is now required for install
+--------------------------------------
+
+SQLAlchemy's ``setup.py`` file has for many years supported operation
+both with Setuptools installed and without; supporting a "fallback" mode
+that uses straight Distutils. As a Setuptools-less Python environment is
+now unheard of, and in order to support the featureset of Setuptools
+more fully, in particular to support py.test's integration with it,
+``setup.py`` now depends on Setuptools fully.
+
+.. seealso::
+
+ :ref:`installation`
+
+:ticket:`3489`
+
+Enabling / Disabling C Extension builds is only via environment variable
+------------------------------------------------------------------------
+
+The C Extensions build by default during install as long as it is possible.
+To disable C extension builds, the ``DISABLE_SQLALCHEMY_CEXT`` environment
+variable was made available as of SQLAlchemy 0.8.6 / 0.9.4. The previous
+approach of using the ``--without-cextensions`` argument has been removed,
+as it relies on deprecated features of setuptools.
+
+.. seealso::
+
+ :ref:`c_extensions`
+
+:ticket:`3500`
+
New Features and Improvements - ORM
===================================
Supported Installation Methods
-------------------------------
-SQLAlchemy supports installation using standard Python "distutils" or
-"setuptools" methodologies. An overview of potential setups is as follows:
-
-* **Plain Python Distutils** - SQLAlchemy can be installed with a clean
- Python install using the services provided via `Python Distutils <http://docs.python.org/distutils/>`_,
- using the ``setup.py`` script. The C extensions as well as Python 3 builds are supported.
-* **Setuptools or Distribute** - 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.
-* **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.
+SQLAlchemy installation is via standard Python methodologies that are
+based on `setuptools <http://pypi.python.org/pypi/setuptools/>`_, either
+by referring to ``setup.py`` directly or by using
+`pip <http://pypi.python.org/pypi/pip/>`_ or other setuptools-compatible
+approaches.
+
+.. versionchanged:: 1.1 setuptools is now required by the setup.py file;
+ plain distutils installs are no longer supported.
Install via pip
---------------
python setup.py install
+.. _c_extensions:
+
Installing the C Extensions
----------------------------------
dealing with result sets. The extensions are supported on both the 2.xx
and 3.xx series of cPython.
-.. versionchanged:: 0.9.0
-
- The C extensions now compile on Python 3 as well as Python 2.
-
``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
case of compatibility/build issues not overcome by the usual "rebuild"
mechanism::
- # *** only in SQLAlchemy 0.9.4 / 0.8.6 or greater ***
export DISABLE_SQLALCHEMY_CEXT=1; python setup.py install
-.. 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.
-
- 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::
-
- python setup.py --without-cextensions install
-
- Or with pip::
-
- pip install --global-option='--without-cextensions' SQLAlchemy
+.. versionchanged:: 1.1 The legacy ``--without-cextensions`` flag has been
+ removed from the installer as it relies on deprecated features of
+ setuptools.
Installing on Python 3
SQLAlchemy runs directly on Python 2 or Python 3, and can be installed in
either environment without any adjustments or code conversion.
-.. versionchanged:: 0.9.0 Python 3 is now supported in place with no 2to3 step
- required.
Installing a Database API
-"""setup.py
-
-Please see README for basic installation instructions.
-
-"""
-
import os
+import platform
import re
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
- 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:
- from distutils.core import setup, Extension
+from distutils.errors import CCompilerError
+from distutils.errors import DistutilsExecError
+from distutils.errors import DistutilsPlatformError
+from setuptools import Extension
+from setuptools import setup
+from setuptools.command.test import test as TestCommand
py3k = False
elif sys.version_info >= (3, 0):
py3k = True
-import platform
cpython = platform.python_implementation() == 'CPython'
ext_modules = [
sources=['lib/sqlalchemy/cextension/resultproxy.c']),
Extension('sqlalchemy.cutils',
sources=['lib/sqlalchemy/cextension/utils.c'])
- ]
+]
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
if sys.platform == 'win32':
cmdclass['build_ext'] = ve_build_ext
+class PyTest(TestCommand):
+ # from https://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands
+ user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
+
+ default_options = ["-n", "4", "-q"]
+
+ def initialize_options(self):
+ TestCommand.initialize_options(self)
+ self.pytest_args = ""
+
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+
+ def run_tests(self):
+ # import here, cause outside the eggs aren't loaded
+ import pytest
+ errno = pytest.main(
+ " ".join(self.default_options) + " " + self.pytest_args)
+ sys.exit(errno)
+
+cmdclass['test'] = PyTest
+
+
def status_msgs(*msgs):
print('*' * 75)
for msg in msgs:
def run_setup(with_cext):
kwargs = extra.copy()
if with_cext:
- if has_feature:
- kwargs['features'] = {'cextensions': Feature(
- "optional C speed-enhancements",
- standard=True,
- ext_modules=ext_modules
- )}
- else:
- kwargs['ext_modules'] = ext_modules
-
- setup(name="SQLAlchemy",
- version=VERSION,
- description="Database Abstraction Library",
- author="Mike Bayer",
- author_email="mike_mp@zzzcomputing.com",
- url="http://www.sqlalchemy.org",
- packages=find_packages('lib'),
- package_dir={'': 'lib'},
- license="MIT License",
- cmdclass=cmdclass,
- tests_require=['pytest >= 2.5.2', 'mock', 'pytest-xdist'],
- test_suite="sqlalchemy.testing.distutils_run",
- long_description=readme,
- classifiers=[
- "Development Status :: 5 - Production/Stable",
- "Intended Audience :: Developers",
- "License :: OSI Approved :: MIT License",
- "Programming Language :: Python",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: Implementation :: CPython",
- "Programming Language :: Python :: Implementation :: Jython",
- "Programming Language :: Python :: Implementation :: PyPy",
- "Topic :: Database :: Front-Ends",
- "Operating System :: OS Independent",
- ],
- **kwargs
- )
+ kwargs['ext_modules'] = ext_modules
+
+ setup(
+ name="SQLAlchemy",
+ version=VERSION,
+ description="Database Abstraction Library",
+ author="Mike Bayer",
+ author_email="mike_mp@zzzcomputing.com",
+ url="http://www.sqlalchemy.org",
+ packages=find_packages('lib'),
+ package_dir={'': 'lib'},
+ license="MIT License",
+ cmdclass=cmdclass,
+ tests_require=['pytest >= 2.5.2', 'mock', 'pytest-xdist'],
+ long_description=readme,
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Programming Language :: Python :: Implementation :: Jython",
+ "Programming Language :: Python :: Implementation :: PyPy",
+ "Topic :: Database :: Front-Ends",
+ "Operating System :: OS Independent",
+ ],
+ **kwargs
+ )
if not cpython:
run_setup(False)