diff --git a/PyInstaller/building/api.py b/PyInstaller/building/api.py index 5515279899..52afda73ba 100644 --- a/PyInstaller/building/api.py +++ b/PyInstaller/building/api.py @@ -840,7 +840,11 @@ def _set_dependencies(self, analysis, path): # relative path needs to be reconstructed from the # name components. if tpl[2] == 'EXTENSION': - ext_components = tpl[0].split('.')[:-1] + # Split on os.path.sep first, to handle additional + # path prefix (e.g., lib-dynload) + ext_components = tpl[0].split(os.path.sep) + ext_components = ext_components[:-1] \ + + ext_components[-1].split('.')[:-1] if ext_components: rel_path = os.path.join(*ext_components) else: diff --git a/PyInstaller/building/build_main.py b/PyInstaller/building/build_main.py index 7bec0420f1..0fcc1523ec 100644 --- a/PyInstaller/building/build_main.py +++ b/PyInstaller/building/build_main.py @@ -480,6 +480,18 @@ def assemble(self): self.binding_redirects[:] = list(set(self.binding_redirects)) logger.info("Found binding redirects: \n%s", self.binding_redirects) + # Filter binaries to adjust path of extensions that come from + # python's lib-dynload directory. Prefix them with lib-dynload + # so that we'll collect them into subdirectory instead of + # directly into _MEIPASS + for idx, tpl in enumerate(self.binaries): + name, path, typecode = tpl + if typecode == 'EXTENSION' \ + and not os.path.dirname(os.path.normpath(name)) \ + and os.path.basename(os.path.dirname(path)) == 'lib-dynload': + name = os.path.join('lib-dynload', name) + self.binaries[idx] = (name, path, typecode) + # Place Python source in data files for the noarchive case. if self.noarchive: # Create a new TOC of ``(dest path for .pyc, source for .py, type)``. diff --git a/news/5583.bugfix.rst b/news/5583.bugfix.rst new file mode 100644 index 0000000000..dc322e7ae0 --- /dev/null +++ b/news/5583.bugfix.rst @@ -0,0 +1 @@ +(OSX) Fix issues with ``pycryptodomex`` on macOS. diff --git a/news/5604.core.rst b/news/5604.core.rst new file mode 100644 index 0000000000..b8b0eb7839 --- /dev/null +++ b/news/5604.core.rst @@ -0,0 +1,5 @@ +Collect python extension modules that correspond to built-ins into +``lib-dynload`` sub-directory instead of directly into bundle's root +directory. This prevents them from shadowing shared libraries with the +same basename that are located in a package and loaded via ``ctypes`` or +``cffi``, and also declutters the bundle's root directory.