fix cryptography recipe
This commit is contained in:
parent
68f0452a38
commit
cd42e78292
2 changed files with 29 additions and 49 deletions
|
@ -12,8 +12,15 @@ class CryptographyRecipe(CythonRecipe):
|
|||
library = "libcryptography.a"
|
||||
depends = ["host_setuptools3", "host_cffi", "cffi", "asn1crypto", "idna", "six"]
|
||||
python_depends = ["setuptools"]
|
||||
cythonize = True
|
||||
cythonize = False
|
||||
pre_build_ext = True
|
||||
include_per_arch = True
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
if self.has_marker("patched"):
|
||||
return
|
||||
self.apply_patch("osrandom.patch")
|
||||
self.set_marker("patched")
|
||||
|
||||
def dest_dir(self):
|
||||
return join(self.ctx.dist_dir, "root", "python3")
|
||||
|
@ -23,10 +30,11 @@ class CryptographyRecipe(CythonRecipe):
|
|||
r = self.get_recipe('openssl', self.ctx)
|
||||
openssl_dir = r.get_build_dir(arch.arch)
|
||||
target_python = Recipe.get_recipe('python3', self.ctx).get_build_dir(arch.arch)
|
||||
env['TOOLCHAIN_PREFIX'] = arch.triple
|
||||
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl'
|
||||
env['LDFLAGS'] += ' -L' + target_python
|
||||
|
||||
env['PYTHON_ROOT'] = join(self.ctx.dist_dir, "root", "python3")
|
||||
env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
|
||||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.8' + \
|
||||
' -I' + join(openssl_dir, 'include') + \
|
||||
' -I' + join(self.ctx.dist_dir, "include", arch.arch, "libffi")
|
||||
|
@ -36,7 +44,8 @@ class CryptographyRecipe(CythonRecipe):
|
|||
' -lssl' + \
|
||||
' -lcrypto' + \
|
||||
' -lffi' + \
|
||||
' -lcffi'
|
||||
' -lcffi ' + \
|
||||
' -lz'
|
||||
return env
|
||||
|
||||
def install(self):
|
||||
|
@ -49,6 +58,22 @@ class CryptographyRecipe(CythonRecipe):
|
|||
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.8', 'site-packages')
|
||||
with cd(build_dir):
|
||||
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
|
||||
|
||||
|
||||
def postbuild_arch(self, arch):
|
||||
py_arch = arch.arch
|
||||
if py_arch == "arm64":
|
||||
py_arch = "x86_64"
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
build_env = self.get_recipe_env(arch)
|
||||
tmp_folder = 'build/temp.macosx-10.15-{}-3.8/build/temp.macosx-10.15-{}-3.8'.format(py_arch, py_arch)
|
||||
for o_file in [
|
||||
"_openssl.o",
|
||||
"_padding.o",
|
||||
]:
|
||||
shprint(sh.Command(build_env['AR']),
|
||||
"-q",
|
||||
"{}/{}".format(self.build_dir, self.library),
|
||||
"{}/{}/{}".format(self.build_dir, tmp_folder, o_file))
|
||||
|
||||
|
||||
recipe = CryptographyRecipe()
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
--- a/src/_cffi_src/openssl/src/osrandom_engine.c 2019-01-22 17:41:49.000000000 +0100
|
||||
+++ b/src/_cffi_src/openssl/src/osrandom_engine.c 2019-08-12 11:47:03.000000000 +0100
|
||||
@@ -243,14 +243,10 @@
|
||||
#if !defined(__APPLE__)
|
||||
getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
|
||||
#else
|
||||
- if (&getentropy != NULL) {
|
||||
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
|
||||
- } else {
|
||||
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
|
||||
- int fd = dev_urandom_fd();
|
||||
- if (fd < 0) {
|
||||
- return 0;
|
||||
- }
|
||||
+ getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
|
||||
+ int fd = dev_urandom_fd();
|
||||
+ if (fd < 0) {
|
||||
+ return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
@@ -266,22 +262,7 @@
|
||||
return dev_urandom_read(buffer, size);
|
||||
#endif
|
||||
case CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS:
|
||||
- while (size > 0) {
|
||||
- /* OpenBSD and macOS restrict maximum buffer size to 256. */
|
||||
- len = size > 256 ? 256 : size;
|
||||
- res = getentropy(buffer, (size_t)len);
|
||||
- if (res < 0) {
|
||||
- ERR_Cryptography_OSRandom_error(
|
||||
- CRYPTOGRAPHY_OSRANDOM_F_RAND_BYTES,
|
||||
- CRYPTOGRAPHY_OSRANDOM_R_GETENTROPY_FAILED,
|
||||
- __FILE__, __LINE__
|
||||
- );
|
||||
- return 0;
|
||||
- }
|
||||
- buffer += len;
|
||||
- size -= len;
|
||||
- }
|
||||
- return 1;
|
||||
+ return 0;
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
Loading…
Reference in a new issue