Fix pyrcytodome not useable on macOS and Linux

This commit is contained in:
Kovid Goyal 2020-11-25 20:57:14 +05:30
parent 3d89c98110
commit 2959f98698
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 2 deletions

View File

@ -15,7 +15,9 @@ from functools import partial
from bypy.constants import (
OUTPUT_DIR, PREFIX, SRC as CALIBRE_DIR, is64bit, python_major_minor_version
)
from bypy.freeze import extract_extension_modules, freeze_python, path_to_freeze_dir
from bypy.freeze import (
extract_extension_modules, fix_pycryptodome, freeze_python, path_to_freeze_dir
)
from bypy.utils import (
create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk
)
@ -158,6 +160,7 @@ def copy_python(env, ext_dir):
pdir = j(env.lib_dir, 'calibre-extensions')
if not os.path.exists(pdir):
os.mkdir(pdir)
fix_pycryptodome(j(env.py_dir, 'site-packages'))
for x in os.listdir(j(env.py_dir, 'site-packages')):
os.rename(j(env.py_dir, 'site-packages', x), j(env.py_dir, x))
os.rmdir(j(env.py_dir, 'site-packages'))

View File

@ -22,7 +22,9 @@ from itertools import repeat
from bypy.constants import (
OUTPUT_DIR, PREFIX, PYTHON, SRC as CALIBRE_DIR, python_major_minor_version
)
from bypy.freeze import extract_extension_modules, freeze_python, path_to_freeze_dir
from bypy.freeze import (
extract_extension_modules, fix_pycryptodome, freeze_python, path_to_freeze_dir
)
from bypy.utils import current_dir, mkdtemp, py_compile, timeit, walk
abspath, join, basename, dirname = os.path.abspath, os.path.join, os.path.basename, os.path.dirname
@ -545,6 +547,7 @@ class Freeze(object):
finally:
if tdir is not None:
shutil.rmtree(tdir)
fix_pycryptodome(self.site_packages)
try:
shutil.rmtree(join(self.site_packages, 'calibre', 'plugins'))
except OSError as err:

View File

@ -30,6 +30,8 @@ class BuildTest(unittest.TestCase):
ctypes.WinDLL(os.path.join(base, x))
except Exception as err:
self.assertTrue(False, 'Failed to load DLL %s with error: %s' % (x, err))
def test_pycryptodome(self):
from Crypto.Cipher import AES
del AES