5757so_ext = get_config_var ("EXT_SUFFIX" )
5858
5959
60- if darwin_native :
61- get_config_vars ()["LDSHARED" ] = get_config_vars ()['LDSHARED_LINUX' ] + " -L" + sys .graal_python_capi_home + " -lpython." + get_config_vars ()["SOABI" ] + " -rpath '@loader_path/../'"
62-
63-
6460def system (cmd , msg = "" ):
6561 logger .debug ("Running command: " + cmd )
6662 status = os .system (cmd )
@@ -70,58 +66,35 @@ def system(cmd, msg=""):
7066
7167def xit (msg , status = - 1 ):
7268 print (msg )
73- exit (- 1 )
69+ sys . exit (- 1 )
7470
7571
7672class CAPIDependency :
7773 _lib_install_dir = os .path .join (site .getuserbase (), "lib" , get_config_var ("SOABI" ))
7874 _include_install_dir = os .path .join (site .getuserbase (), "include" )
7975
80- def __init__ (self , lib_name , package_spec , url ):
76+ def __init__ (self , lib_name , package_spec , src_var ):
8177 self .lib_name = lib_name
8278 if "==" in package_spec :
8379 self .package_name , _ , self .version = package_spec .rpartition ("==" )
8480 else :
8581 self .package_name = self .package_spec
8682 self .version = None
87- self .url = url
83+ self .src_var = src_var
8884
8985 def download (self ):
9086 import tempfile
91- package_pattern = os .environ .get ("GINSTALL_PACKAGE_PATTERN" , None )
92- package_version_pattern = os .environ .get ("GINSTALL_PACKAGE_VERSION_PATTERN" , None )
93- tempdir = tempfile .mkdtemp ()
94- package_name = self .package_name
95-
96- if package_pattern and package_version_pattern :
97- if self .version :
98- url = package_version_pattern % (package_name , self .version )
99- else :
100- url = package_pattern % package_name
101- else :
102- url = self .url
103-
104- logger .info ("Downloading dependency %s from %s to %s" % (package_name , url , tempdir ))
105-
106- # honor env var 'HTTP_PROXY' and 'HTTPS_PROXY'
107- os_env = os .environ
108- curl_opts = []
109- if url .startswith ("http://" ) and "HTTP_PROXY" in os_env :
110- curl_opts += ["--proxy" , os_env ["HTTP_PROXY" ]]
111- elif url .startswith ("https://" ) and "HTTPS_PROXY" in os_env :
112- curl_opts += ["--proxy" , os_env ["HTTPS_PROXY" ]]
113-
114- system ("curl -L %s -o %s/%s %s" % (" " .join (curl_opts ), tempdir , package_name , url ), msg = "Download error" )
115- if url .endswith (".tar.gz" ):
116- system ("tar xzf %s/%s -C %s" % (tempdir , package_name , tempdir ), msg = "Error extracting tar.gz" )
117- elif url .endswith (".tar.bz2" ):
118- system ("tar xjf %s/%s -C %s" % (tempdir , package_name , tempdir ), msg = "Error extracting tar.bz2" )
119- elif url .endswith (".zip" ):
120- system ("unzip -u %s/%s -d %s" % (tempdir , package_name , tempdir ), msg = "Error extracting zip" )
87+ tempdir = tempfile .mktemp ()
88+ src_archive = os .environ .get (self .src_var , None )
89+ if src_archive :
90+ shutil .copytree (src_archive , tempdir )
12191 else :
122- xit ("Unknown file type: %s " % package_name )
92+ xit ("FATAL: Please set the environment variable %s to the location of the source archive of %s " % ( src_archive_var , lib_name ) )
12393 return tempdir
12494
95+ def conftest (self ):
96+ return False
97+
12598 @staticmethod
12699 def _ensure_dir (dir ):
127100 if not (os .path .isdir (dir ) and os .path .exists (dir )):
@@ -230,7 +203,7 @@ def __init__(self, name, subdir="modules", files=None, deps=[]):
230203 self .files = [name + ".c" ]
231204
232205 def __call__ (self ):
233- libs = ["polyglot-mock" ] if darwin_native else [ ]
206+ libs = []
234207 library_dirs = []
235208 include_dirs = []
236209 runtime_library_dirs = []
@@ -247,8 +220,6 @@ def __call__(self):
247220 if dep .lib_install_dir :
248221 libs .append (dep .lib_name )
249222 library_dirs .append (dep .lib_install_dir )
250- #runtime_library_dirs.append(dep.lib_install_dir)
251- extra_link_args .append ("-Wl,-rpath," + dep .lib_install_dir )
252223
253224 # If the dependency provides a header file, add the include path
254225 if dep .include_install_dir :
@@ -272,44 +243,26 @@ def __call__(self):
272243 NativeBuiltinModule ("_mmap" ),
273244 NativeBuiltinModule ("_struct" ),
274245 # the above modules are more core, we need them first to deal with later, more complex modules with dependencies
275- NativeBuiltinModule ("_bz2" , deps = [Bzip2Depedency ("bz2" , "bzip2==1.0.8" , "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz " )]),
246+ NativeBuiltinModule ("_bz2" , deps = [Bzip2Depedency ("bz2" , "bzip2==1.0.8" , "BZIP2 " )]),
276247)
277248
278249
279- class BootstrapContextManager :
280- def __enter__ (self ):
281- # Very special case on Darwin native: for building 'libpython*.dylib' we must not try to link against i
282- # 'libpython', of course. It is special for Darwin because we don't link against it on Linux.
283- if darwin_native :
284- self .default_link_args = get_config_var ("LDSHARED" )
285- assert get_config_vars ()["LDSHARED" ] == get_config_var ("LDSHARED" )
286- get_config_vars ()["LDSHARED" ] = get_config_vars ()["LDSHARED_LINUX" ]
287-
288- def __exit__ (self , typ = None , val = None , tb = None ):
289- if darwin_native :
290- get_config_vars ()["LDSHARED" ] = self .default_link_args
291-
292-
293250def build_libpython (capi_home ):
294251 src_dir = os .path .join (__dir__ , "src" )
295252 files = [os .path .abspath (os .path .join (src_dir , f )) for f in os .listdir (src_dir ) if f .endswith (".c" )]
296253 module = Extension (libpython_name ,
297254 sources = files ,
298255 extra_compile_args = cflags_warnings ,
299- # Darwin's linker is pretty pedantic so we need to avoid any unresolved syms. To do so, we use
300- # 'libpolyglot-mock' that provides definitions for polyglot functions and we define an install name for this lib.
301- extra_link_args = ["-lpolyglot-mock" , "-Wl,-install_name,@rpath/" + libpython_name + so_ext ] if darwin_native else [],
302256 )
303257 args = [verbosity , 'build' , 'install_lib' , '-f' , '--install-dir=%s' % capi_home , "clean" ]
304- with BootstrapContextManager ():
305- setup (
306- script_name = 'setup' + libpython_name ,
307- script_args = args ,
308- name = libpython_name ,
309- version = '1.0' ,
310- description = "Graal Python's C API" ,
311- ext_modules = [module ],
312- )
258+ setup (
259+ script_name = 'setup' + libpython_name ,
260+ script_args = args ,
261+ name = libpython_name ,
262+ version = '1.0' ,
263+ description = "Graal Python's C API" ,
264+ ext_modules = [module ],
265+ )
313266
314267def build_builtin_exts (capi_home ):
315268 args = [verbosity , 'build' , 'install_lib' , '-f' , '--install-dir=%s/modules' % capi_home , "clean" ]
0 commit comments