diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-02-21 09:52:10 +0800 | 
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-02-20 20:52:10 -0500 | 
| commit | 5cfaa5b79d446e1c63de3948e7558cd00561ea1f (patch) | |
| tree | 75cbee0953f498757b8758f76b439f897c40d9e5 /src/_cffi_src | |
| parent | 20a441870be8dce22cb9cc2046b3c6cb3736e629 (diff) | |
| download | cryptography-5cfaa5b79d446e1c63de3948e7558cd00561ea1f.tar.gz cryptography-5cfaa5b79d446e1c63de3948e7558cd00561ea1f.tar.bz2 cryptography-5cfaa5b79d446e1c63de3948e7558cd00561ea1f.zip | |
encode the package version in the shared object (#4756)
* encode the package version in the shared object
* review feedback
* move into build_ffi so the symbol is in all shared objects
* review feedback
Diffstat (limited to 'src/_cffi_src')
| -rw-r--r-- | src/_cffi_src/utils.py | 13 | 
1 files changed, 13 insertions, 0 deletions
| diff --git a/src/_cffi_src/utils.py b/src/_cffi_src/utils.py index d3dd18a4..eecd6ea1 100644 --- a/src/_cffi_src/utils.py +++ b/src/_cffi_src/utils.py @@ -4,6 +4,7 @@  from __future__ import absolute_import, division, print_function +import os  import sys  from distutils.ccompiler import new_compiler  from distutils.dist import Distribution @@ -11,6 +12,13 @@ from distutils.dist import Distribution  from cffi import FFI +# Load the cryptography __about__ to get the current package version +base_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +about = {} +with open(os.path.join(base_src, "cryptography", "__about__.py")) as f: +    exec(f.read(), about) + +  def build_ffi_for_binding(module_name, module_prefix, modules, libraries=[],                            extra_compile_args=[], extra_link_args=[]):      """ @@ -55,6 +63,11 @@ def build_ffi_for_binding(module_name, module_prefix, modules, libraries=[],  def build_ffi(module_name, cdef_source, verify_source, libraries=[],                extra_compile_args=[], extra_link_args=[]):      ffi = FFI() +    # Always add the CRYPTOGRAPHY_PACKAGE_VERSION to the shared object +    cdef_source += "\nstatic const char *const CRYPTOGRAPHY_PACKAGE_VERSION;" +    verify_source += '\n#define CRYPTOGRAPHY_PACKAGE_VERSION "{}"'.format( +        about["__version__"] +    )      ffi.cdef(cdef_source)      ffi.set_source(          module_name, | 
