-
Notifications
You must be signed in to change notification settings - Fork 782
Add a patch that enable to use libraries exposed via LIBRARY_PATH or #23042
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| diff -ruN Python-3.11.5.orig/Lib/ctypes/__init__.py Python-3.11.5/Lib/ctypes/__init__.py | ||
| --- Python-3.11.5.orig/Lib/ctypes/__init__.py 2025-06-03 17:24:09.817225787 +0200 | ||
| +++ Python-3.11.5/Lib/ctypes/__init__.py 2025-06-03 17:26:02.851166381 +0200 | ||
| @@ -13,6 +13,8 @@ | ||
| from _ctypes import ArgumentError | ||
|
|
||
| from struct import calcsize as _calcsize | ||
| +from ctypes import util | ||
| +import re | ||
|
|
||
| if __version__ != _ctypes_version: | ||
| raise Exception("Version number mismatch", __version__, _ctypes_version) | ||
| @@ -349,6 +351,11 @@ | ||
| flags |= _FUNCFLAG_USE_ERRNO | ||
| if use_last_error: | ||
| flags |= _FUNCFLAG_USE_LASTERROR | ||
| + if _os.name == "posix": | ||
| + if name and name.endswith(".so"): | ||
| + s = re.sub(r'lib', '', name) | ||
| + s = re.sub(r'\..*', '', s) | ||
| + self._name=util._findLib_ld(s) | ||
| if _sys.platform.startswith("aix"): | ||
| """When the name contains ".a(" and ends with ")", | ||
| e.g., "libFOO.a(libFOO.so)" - this is taken to be an | ||
| diff -ruN Python-3.11.5.orig/Lib/ctypes/util.py Python-3.11.5/Lib/ctypes/util.py | ||
| --- Python-3.11.5.orig/Lib/ctypes/util.py 2025-06-03 17:24:09.816225753 +0200 | ||
| +++ Python-3.11.5/Lib/ctypes/util.py 2025-06-03 17:28:52.212009753 +0200 | ||
| @@ -209,7 +209,7 @@ | ||
| expr = os.fsencode(expr) | ||
|
|
||
| try: | ||
| - proc = subprocess.Popen(('/sbin/ldconfig', '-r'), | ||
| + proc = subprocess.Popen((os.environ.get('EPREFIX') + '/sbin/ldconfig', '-r'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is another reason why we should resolve things at the EasyBlock level: there, we can query if EasyBuild was configured with a |
||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.DEVNULL) | ||
| except OSError: # E.g. command not found | ||
| @@ -301,7 +301,14 @@ | ||
| # See issue #9998 for why this is needed | ||
| expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) | ||
| cmd = ['ld', '-t'] | ||
| - libpath = os.environ.get('LD_LIBRARY_PATH') | ||
| + libpath = [] | ||
| + if os.getenv('EPREFIX'): | ||
| + libpath.append(os.getenv('EPREFIX')) | ||
| + if os.getenv('LD_LIBRARY_PATH'): | ||
| + libpath.append(os.getenv('LD_LIBRARY_PATH')) | ||
| + if os.getenv('LIBRARY_PATH'): | ||
| + libpath.append(os.getenv('LIBRARY_PATH')) | ||
| + libpath = ':'.join(libpath) | ||
| if libpath: | ||
| for d in libpath.split(':'): | ||
| cmd.extend(['-L', d]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what's happening here. What issue is this actually resolving? Also, invoking _findLib_ld means we need to make absolutely sure that that searches the correct path (though I guess that's ensured by the changes below as well)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh, wait, this is where you overwrite the name with the full path already? I.e. this, together with the change below, makes sure we get something like
/home/casparl/eessi/versions/2023.06/software/linux/x86_64/amd/zen2/software/Blosc2/2.13.2-GCCcore-13.2.0/lib/libblosc2.soback, and then the rest of theCDLLcall just acts on that full path?In other words: this is where we are actually pretending the calling code called the function with the full path, thus avoiding the whole issue?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, by overriding
self._name