diff options
author | Donald Stufft <donald@stufft.io> | 2014-01-07 14:56:46 -0800 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2014-01-07 14:56:46 -0800 |
commit | 7ec30af9a58647d1e38bb78b5381e64af67128a6 (patch) | |
tree | 0bfcb081074648c95356508df5b5323b484a4d00 /setup.py | |
parent | 168c29d6d74060b0d9f592b740f8913cc5d07c5e (diff) | |
parent | 5e5316de9ca968f646aa04301fcf3109aef0473f (diff) | |
download | cryptography-7ec30af9a58647d1e38bb78b5381e64af67128a6.tar.gz cryptography-7ec30af9a58647d1e38bb78b5381e64af67128a6.tar.bz2 cryptography-7ec30af9a58647d1e38bb78b5381e64af67128a6.zip |
Merge pull request #392 from alex/setup-install-extension
All the necessary things for setup.py to build cffi stuff
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 37 |
1 files changed, 31 insertions, 6 deletions
@@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import os +from distutils.command.build import build from setuptools import setup, find_packages @@ -25,14 +26,34 @@ with open(os.path.join(base_dir, "cryptography", "__about__.py")) as f: CFFI_DEPENDENCY = "cffi>=0.6" SIX_DEPENDENCY = "six>=1.4.1" -install_requires = [ +requirements = [ CFFI_DEPENDENCY, SIX_DEPENDENCY ] -setup_requires = [ - CFFI_DEPENDENCY, -] + +class cffi_build(build): + """ + This class exists, instead of just providing ``ext_modules=[...]`` directly + in ``setup()`` because importing cryptography requires we have several + packages installed first. + + By doing the imports here we ensure that packages listed in + ``setup_requires`` are already installed. + """ + + def finalize_options(self): + from cryptography.hazmat.bindings.openssl.binding import Binding + from cryptography.hazmat.primitives import constant_time, padding + + self.distribution.ext_modules = [ + Binding().ffi.verifier.get_extension(), + constant_time._ffi.verifier.get_extension(), + padding._ffi.verifier.get_extension() + ] + + build.finalize_options(self) + with open(os.path.join(base_dir, "README.rst")) as f: long_description = f.read() @@ -74,9 +95,13 @@ setup( packages=find_packages(exclude=["tests", "tests.*"]), - install_requires=install_requires, - setup_requires=setup_requires, + install_requires=requirements, + setup_requires=requirements, # for cffi zip_safe=False, + ext_package="cryptography", + cmdclass={ + "build": cffi_build, + } ) |