@@ -302,7 +302,7 @@ def extra_options():
302302 'ulimit_unlimited' : [False , "Ensure stack size limit is set to '%s' during build" % UNLIMITED , CUSTOM ],
303303 'use_lto' : [None , "Build with Link Time Optimization (>= v3.7.0, potentially unstable on some toolchains). "
304304 "If None: auto-detect based on toolchain compiler (version)" , CUSTOM ],
305- 'patch_custom_ctypes ' : [None , "The ctypes module strongly relies on LD_LIBRARY_PATH to find "
305+ 'patch_ctypes_ld_library_path ' : [None , "The ctypes module strongly relies on LD_LIBRARY_PATH to find "
306306 "libraries. This allows specifying a patch that will only be "
307307 "applied if EasyBuild is configured to filter LD_LIBRARY_PATH, in "
308308 "order to make sure ctypes can still find libraries without it. "
@@ -366,27 +366,32 @@ def fetch_step(self, *args, **kwargs):
366366 # libraries. But, we want to do the patching conditionally on EasyBuild configuration (i.e. which env vars
367367 # are filtered), hence this setup based on the custom config option 'patches_custom_ctypes'
368368 filtered_env_vars = build_option ('filter_env_vars' ) or []
369- additional_patches = []
370- if self . cfg [ 'patch_custom_ctypes' ] is not None :
371- additional_patches = [ self . cfg [ 'patch_custom_ctypes' ]]
372- checksums = self . cfg [ 'checksums' ]
373- sources = self . cfg [ 'sources' ]
374- if ( 'LD_LIBRARY_PATH' in filtered_env_vars and len ( additional_patches ) > 0 ):
369+ patch_ctypes_ld_library_path = self . cfg . get ( 'patch_ctypes_ld_library_path' )
370+ if (
371+ 'LD_LIBRARY_PATH' in filtered_env_vars and
372+ 'LIBRARY_PATH' not in filtered_env_vars and
373+ patch_ctypes_ld_library_path
374+ ):
375375 # Some sanity checking so we can raise an early and clear error if needed
376- if len (additional_patches ) + len (sources ) == len (checksums ):
376+ # We expect a (one) checksum for the patch_ctypes_ld_library_path
377+ checksums = self .cfg ['checksums' ]
378+ sources = self .cfg ['sources' ]
379+ patches = self .cfg .get ('patches' )
380+ len_patches = len (patches ) if patches else 0
381+ if len_patchs + len (sources ) + 1 == len (checksums ):
377382 msg = "EasyBuild was configured to filter LD_LIBRARY_PATH (and not to filter LIBRARY_PATH). "
378383 msg += "The ctypes module relies heavily on LD_LIBRARY_PATH for locating its libraries. "
379384 msg += "The following patches will be applied to make sure ctypes.CDLL, ctypes.cdll.LoadLibrary "
380- msg += f"and ctypes.util.find_library will still work correctly: { additional_patches } ."
385+ msg += f"and ctypes.util.find_library will still work correctly: { patch_ctypes_ld_library_path } ."
381386 self .log .info (msg )
382387 self .log .info (f"Original list of patches: { self .cfg ['patches' ]} " )
383- self .log .info (f"List of patches to be added: { additional_patches } " )
384- self .cfg .update ('patches' , additional_patches )
388+ self .log .info (f"Patch to be added: { patch_ctypes_ld_library_path } " )
389+ self .cfg .update ('patches' , [ patch_ctypes_ld_library_path ] )
385390 self .log .info (f"Updated list of patches: { self .cfg ['patches' ]} " )
386391 else :
387392 msg = "The length of 'checksums' (%s) was not equal to the total amount of sources (%s) + patches (%s)"
388- msg += ". Did you forget to add a checksum for patch_custom_ctypes ?."
389- raise EasyBuildError (msg , len (checksums ), len (sources ), len (additional_patches ))
393+ msg += ". Did you forget to add a checksum for patch_ctypes_ld_library_path ?."
394+ raise EasyBuildError (msg , len (checksums ), len (sources ), len (len_patches + 1 ))
390395
391396 super ().fetch_step (* args , ** kwargs )
392397
0 commit comments