-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch ctypes
find_library
function search path
#2339
Comments
This is correct, as Homebrew installs extensions for the Homebrew-provided Python installation. Pyenv makes its own, independent Python installations. You need to switch to that installation and use Pip to install extension modules. I'm not sure when the code that you showed would fire, but it looks like something that would only be used in a Framework build of Python (with |
In this case I have no idea how to make this happen. Step to reproduce:
|
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. |
Thanks for the detailed explanation. For anyone who finds their way here via a google search, one easy workaround that worked for me was to simply create a symbolic link from one of the unused locations in the ctypes search path to the homebrew library path. For example, /usr/local was empty on my machine so I simply did the following: |
Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.
Prerequisite
pyenv
and the defaultpython-build
plugin only. Please refrain from reporting issues of other plugins here.Description
env PYENV_DEBUG=1 <faulty command> 2>&1 | tee trace.log
and attachtrace.log
. E.g. if you have a problem with installing Python, runenv PYENV_DEBUG=1 pyenv install -v <version> 2>&1 | tee trace.log
(note the-v
option topyenv install
).On a mac m1, using homebrew to install C extension puts them in
/opt/homebrew/lib
. The source code of python is quite clear:https://github.com/python/cpython/blob/main/Lib/ctypes/macholib/dyld.py#L29-L33 it searches trough a list of hardcoded path. Macport patches this file: https://github.com/macports/macports-ports/blob/master/lang/python310/files/patch-Lib-ctypes-macholib-dyld.py.diff in order for him to work.
normally we can set the
DYLD_LIBRARY_PATH
to override the path but SIP limit this possibility, example:FOO=BAR python -c "import os; print(os.environ['FOO'])"
work as expected, whileDYLD_LIBRARY_PATH=~/lol python -c "import os; os.environ['DYLD_LIBRARY_PATH']"
raise an exception.As a solution a configurable path when building python would have been nice, but I cannot found any (not an expert in python build though). Otherwise a patch like here: https://github.com/pyenv/pyenv/blob/master/plugins/python-build/share/python-build/patches/3.7.13/Python-3.7.13/0001-Port-ctypes-and-system-libffi-patches-for-arm64-macO.patch
The text was updated successfully, but these errors were encountered: