From 49e583a54a65d9e1972d57e3972efa19ea282a8e Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 9 Sep 2021 17:43:38 +0100 Subject: [PATCH 1/3] Add docs entry regarding DYLD_LIBRARY_PATH Fix #816 --- docs/faq.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 9b70577b1..4fc92e922 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -251,11 +251,11 @@ To quickly test your config without doing a git push and waiting for your code t You might need to install something on the build machine. You can do this with apt/yum, brew or choco, using the [`CIBW_BEFORE_ALL`](options.md#before-all) option. Or, for a Python dependency, consider [adding it to pyproject.toml](#cibw-options-alternatives-deps). -### ModuleNotFoundError on macOS +### macOS: ModuleNotFoundError Calling cibuildwheel from a python3 script and getting a `ModuleNotFoundError`? Due to a (fixed) [bug](https://bugs.python.org/issue22490) in CPython, you'll need to [unset the `__PYVENV_LAUNCHER__` variable](https://github.com/pypa/cibuildwheel/issues/133#issuecomment-478288597) before activating a venv. -### 'No module named XYZ' errors after running cibuildwheel on macOS +### macOS: 'No module named XYZ' errors after running cibuildwheel `cibuildwheel` on Mac installs the distributions from Python.org system-wide during its operation. This is necessary, but it can cause some confusing errors after cibuildwheel has finished. @@ -279,7 +279,21 @@ python3 -m pip install twine python3 -m twine upload wheelhouse/*.whl ``` -### 'ImportError: DLL load failed: The specific module could not be found' error on Windows +### macOS: Passing DYLD_LIBRARY_PATH to delocate + +macOS has built-in [System Integrity protections](https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html) which limits the use of `DYLD_LIBRARY_PATH` and `LD_LIBRARY_PATH` so that it does not automatically pass to children processes. This means if you set `DYLD_LIBRARY_PATH` before running cibuildwheel, or even set it in `CIBW_ENVIRONMENT`, it will be stripped out of the environment before delocate is called. + +To work around this, use a different environment variable such as `REPAIR_LIBRARY_PATH` to store the library path, and set `DYLD_LIBRARY_PATH` in [`CIBW_REPAIR_WHEEL_COMMAND_MACOS`](https://cibuildwheel.readthedocs.io/en/stable/options/#repair-wheel-command), like this: + +```yaml +CIBW_REPAIR_WHEEL_COMMAND_MACOS: > + DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} && + DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} +``` + +See [#816](https://github.com/pypa/cibuildwheel/issues/816), thanks to @phoerious for reporting. + +### Windows: 'ImportError: DLL load failed: The specific module could not be found' Visual Studio and MSVC link the compiled binary wheels to the Microsoft Visual C++ Runtime. Normally, these are included with Python, but when compiling with a newer version of Visual Studio, it is possible users will run into problems on systems that do not have these runtime libraries installed. The solution is to ask users to download the corresponding Visual C++ Redistributable from the [Microsoft website](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) and install it. Since a Python installation normally includes these VC++ Redistributable files for [the version of the MSVC compiler used to compile Python](https://wiki.python.org/moin/WindowsCompilers), this is typically only a problem when compiling a Python C extension with a newer compiler. From efa161e329161690e08aa8ebaf6565c582c33a1c Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sat, 11 Sep 2021 13:02:46 +0100 Subject: [PATCH 2/3] Add tabs --- docs/faq.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 4fc92e922..5ba2890de 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -285,11 +285,23 @@ macOS has built-in [System Integrity protections](https://developer.apple.com/li To work around this, use a different environment variable such as `REPAIR_LIBRARY_PATH` to store the library path, and set `DYLD_LIBRARY_PATH` in [`CIBW_REPAIR_WHEEL_COMMAND_MACOS`](https://cibuildwheel.readthedocs.io/en/stable/options/#repair-wheel-command), like this: -```yaml -CIBW_REPAIR_WHEEL_COMMAND_MACOS: > - DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} && - DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} -``` +!!! tab examples "Environment variables" + + ```yaml + CIBW_REPAIR_WHEEL_COMMAND_MACOS: > + DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} && + DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} + ``` + +!!! tab examples "pyproject.toml" + + ```toml + [tool.cibuildwheel.macos] + repair_wheel_command = [ + "DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel}", + "DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}" + ] + ``` See [#816](https://github.com/pypa/cibuildwheel/issues/816), thanks to @phoerious for reporting. From 15123a0e2921bf401a3752f7c14ee53c0c556e55 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sat, 11 Sep 2021 13:51:14 +0100 Subject: [PATCH 3/3] Update docs/faq.md Co-authored-by: Henry Schreiner --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 5ba2890de..2e1f5f4ea 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -297,7 +297,7 @@ To work around this, use a different environment variable such as `REPAIR_LIBRAR ```toml [tool.cibuildwheel.macos] - repair_wheel_command = [ + repair-wheel-command = [ "DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel}", "DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}" ]