44from spack .package import *
55
66
7+ def find_libclang (root ):
8+ lib_ext = "dylib" if sys .platform == "darwin" else "so"
9+ regex = re .compile (rf"libclang(?:-\d+)?.{ lib_ext } (?:.\d+)?" )
10+ for root , dirs , files in os .walk (root ):
11+ for file in files :
12+ if regex .match (file ):
13+ return os .path .join (root , file )
14+
15+
716class H2yaml (PythonPackage ):
817 """Matrices describing affine transformation of the plane."""
918
@@ -29,11 +38,30 @@ class H2yaml(PythonPackage):
2938
3039 def setup_build_environment (self , env ):
3140 """Wrapper until spack has a real implementation of setup_test_environment()"""
41+ if self .version < Version ("0.4.1" ):
42+ return
43+
3244 if self .run_tests :
3345 # Workarround to some bug with pythonpath
3446 env .prepend_path ("PYTHONPATH" , self .stage .source_path )
3547 self .setup_test_environment (env )
3648
49+ def setup_run_environment (self , env ):
50+ if self .version < Version ("0.4.1" ):
51+ return
52+
53+ super ().setup_run_environment (env )
54+ s = self .spec ["llvm" ]
55+ llvm_config = os .path .join (s .prefix .bin , "llvm-config-" + str (s .version [0 ]))
56+ if not os .path .exists (llvm_config ):
57+ llvm_config = os .path .join (s .prefix .bin , "llvm-config" )
58+ output = Executable (llvm_config )("--libdir" , output = str , error = str , fail_on_error = False )
59+ lib_path = output .rstrip ()
60+ env .set ("LIBCLANG_LIBRARY_FILE" , find_libclang (lib_path ))
61+
62+ def setup_test_environment (self , env ):
63+ self .setup_run_environment (env )
64+
3765 @run_after ("install" )
3866 @on_package_attributes (run_tests = True )
3967 def install_test (self ):
0 commit comments