--- a/setup.py 2014-02-22 22:35:18.000000000 +0100 +++ b/setup.py 2014-03-31 18:02:28.144820932 +0200 @@ -12,6 +12,7 @@ # limitations under the License. import os from distutils.command.build import build +from distutils.command.install import install from setuptools import setup, find_packages @@ -32,6 +33,27 @@ ] +def get_ext_modules(): + from cryptography.hazmat.bindings.commoncrypto.binding import ( + Binding as CommonCryptoBinding + ) + from cryptography.hazmat.bindings.openssl.binding import ( + Binding as OpenSSLBinding + ) + from cryptography.hazmat.primitives import constant_time, padding + + ext_modules = [ + OpenSSLBinding().ffi.verifier.get_extension(), + constant_time._ffi.verifier.get_extension(), + padding._ffi.verifier.get_extension() + ] + if CommonCryptoBinding.is_available(): + ext_modules.append( + CommonCryptoBinding().ffi.verifier.get_extension() + ) + return ext_modules + + class cffi_build(build): """ This class exists, instead of just providing ``ext_modules=[...]`` directly @@ -43,25 +65,17 @@ """ def finalize_options(self): - from cryptography.hazmat.bindings.commoncrypto.binding import ( - Binding as CommonCryptoBinding - ) - from cryptography.hazmat.bindings.openssl.binding import ( - Binding as OpenSSLBinding - ) - from cryptography.hazmat.primitives import constant_time, padding + self.distribution.ext_modules = get_ext_modules() + build.finalize_options(self) - self.distribution.ext_modules = [ - OpenSSLBinding().ffi.verifier.get_extension(), - constant_time._ffi.verifier.get_extension(), - padding._ffi.verifier.get_extension() - ] - if CommonCryptoBinding.is_available(): - self.distribution.ext_modules.append( - CommonCryptoBinding().ffi.verifier.get_extension() - ) - build.finalize_options(self) +class cffi_install(install): + """ + As a consequence... + """ + def finalize_options(self): + self.distribution.ext_modules = get_ext_modules() + install.finalize_options(self) with open(os.path.join(base_dir, "README.rst")) as f: @@ -111,5 +125,6 @@ ext_package="cryptography", cmdclass={ "build": cffi_build, + "install": cffi_install } )