summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py55
1 files changed, 29 insertions, 26 deletions
diff --git a/setup.py b/setup.py
index 2685d4c6e..5b97cb9fe 100644
--- a/setup.py
+++ b/setup.py
@@ -6,18 +6,14 @@ from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError
-from setuptools import Extension
+from setuptools import Distribution as _Distribution, Extension
from setuptools import setup
+from setuptools import find_packages
from setuptools.command.test import test as TestCommand
-py3k = False
-
cmdclass = {}
-extra = {}
if sys.version_info < (2, 6):
raise Exception("SQLAlchemy requires Python 2.6 or higher.")
-elif sys.version_info >= (3, 0):
- py3k = True
cpython = platform.python_implementation() == 'CPython'
@@ -66,8 +62,21 @@ class ve_build_ext(build_ext):
cmdclass['build_ext'] = ve_build_ext
+class Distribution(_Distribution):
+
+ def has_ext_modules(self):
+ # We want to always claim that we have ext_modules. This will be fine
+ # if we don't actually have them (such as on PyPy) because nothing
+ # will get built, however we don't want to provide an overally broad
+ # Wheel package when building a wheel without C support. This will
+ # ensure that Wheel knows to treat us as if the build output is
+ # platform specific.
+ return True
+
+
class PyTest(TestCommand):
- # from https://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands
+ # 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"]
@@ -98,31 +107,24 @@ def status_msgs(*msgs):
print('*' * 75)
-def find_packages(location):
- packages = []
- for pkg in ['sqlalchemy']:
- for _dir, subdirectories, files in (
- os.walk(os.path.join(location, pkg))):
- if '__init__.py' in files:
- tokens = _dir.split(os.sep)[len(location.split(os.sep)):]
- packages.append(".".join(tokens))
- return packages
-
-v_file = open(os.path.join(os.path.dirname(__file__),
- 'lib', 'sqlalchemy', '__init__.py'))
-VERSION = re.compile(r".*__version__ = '(.*?)'",
- re.S).match(v_file.read()).group(1)
-v_file.close()
+with open(
+ os.path.join(
+ os.path.dirname(__file__),
+ 'lib', 'sqlalchemy', '__init__.py')) as v_file:
+ VERSION = re.compile(
+ r".*__version__ = '(.*?)'",
+ re.S).match(v_file.read()).group(1)
-r_file = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
-readme = r_file.read()
-r_file.close()
+with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as r_file:
+ readme = r_file.read()
def run_setup(with_cext):
- kwargs = extra.copy()
+ kwargs = {}
if with_cext:
kwargs['ext_modules'] = ext_modules
+ else:
+ kwargs['ext_modules'] = []
setup(
name="SQLAlchemy",
@@ -149,6 +151,7 @@ def run_setup(with_cext):
"Topic :: Database :: Front-Ends",
"Operating System :: OS Independent",
],
+ distclass=Distribution,
**kwargs
)