aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2014-07-12 00:52:58 +0200
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-09-29 11:44:00 -0500
commitc9b83f7bee7e36678849d684de40331c278617fa (patch)
tree24794a78488dfb927893ad588044317f39d12a6d /setup.py
parent147805a901f2c848501edbbd1daa5a129d903d04 (diff)
downloadcryptography-c9b83f7bee7e36678849d684de40331c278617fa.tar.gz
cryptography-c9b83f7bee7e36678849d684de40331c278617fa.tar.bz2
cryptography-c9b83f7bee7e36678849d684de40331c278617fa.zip
Work around for side effects in setup.py script
Disables setup_requires and related magic for setup.py commands clean, egg_info and sdist and the options --version and --help. See also https://github.com/pyca/cryptography/issues/1253
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/setup.py b/setup.py
index 347dbe82..7465c31f 100644
--- a/setup.py
+++ b/setup.py
@@ -140,6 +140,37 @@ class PyTest(test):
sys.exit(errno)
+def keywords_with_side_effects():
+ """
+ Get a dictionary with setup keywords that (can) have side effects.
+
+ This setup.py script uses the setuptools 'setup_requires' feature because
+ this is required by the cffi package to compile extension modules. The
+ purpose of ``keywords_with_side_effects()`` is to avoid triggering the cffi
+ build process as a result of any of the following ``setup.py`` invocations:
+
+ - ``python setup.py --help-commands``
+ - ``python setup.py --help``
+ - ``python setup.py --version``
+ - ``python setup.py clean``
+ - ``python setup.py egg_info``
+
+ This function is based on the `setup.py script of SciPy`_ (see also the
+ discussion in `pip issue #25`_).
+
+ .. _pip issue #25: https://github.com/pypa/pip/issues/25
+ .. _setup.py script of SciPy: https://github.com/scipy/scipy/blob/master/setup.py
+ """
+ if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
+ sys.argv[1] in ('--help-commands', '--version', 'clean', 'egg_info')):
+ return {}
+ else:
+ return dict(setup_requires=requirements,
+ cmdclass=dict(build=CFFIBuild,
+ install=CFFIInstall,
+ test=PyTest))
+
+
with open(os.path.join(base_dir, "README.rst")) as f:
long_description = f.read()
@@ -182,19 +213,13 @@ setup(
include_package_data=True,
install_requires=requirements,
- setup_requires=requirements,
tests_require=test_requirements,
# for cffi
zip_safe=False,
ext_package="cryptography",
- cmdclass={
- "build": CFFIBuild,
- "install": CFFIInstall,
- "test": PyTest,
- },
-
entry_points={
"cryptography.backends": backends,
- }
+ },
+ **keywords_with_side_effects()
)