Skip to content

Commit fef3edb

Browse files
committed
Do not insert absolute path dep to libpython.
1 parent 35c73b9 commit fef3edb

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

graalpython/com.oracle.graal.python.cext/setup.py

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@
5757
so_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-
6460
def system(cmd, msg=""):
6561
logger.debug("Running command: " + cmd)
6662
status = os.system(cmd)
@@ -230,7 +226,7 @@ def __init__(self, name, subdir="modules", files=None, deps=[]):
230226
self.files = [name + ".c"]
231227

232228
def __call__(self):
233-
libs = ["polyglot-mock"] if darwin_native else []
229+
libs = []
234230
library_dirs = []
235231
include_dirs = []
236232
runtime_library_dirs = []
@@ -247,8 +243,6 @@ def __call__(self):
247243
if dep.lib_install_dir:
248244
libs.append(dep.lib_name)
249245
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)
252246

253247
# If the dependency provides a header file, add the include path
254248
if dep.include_install_dir:
@@ -276,40 +270,22 @@ def __call__(self):
276270
)
277271

278272

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-
293273
def build_libpython(capi_home):
294274
src_dir = os.path.join(__dir__, "src")
295275
files = [os.path.abspath(os.path.join(src_dir, f)) for f in os.listdir(src_dir) if f.endswith(".c")]
296276
module = Extension(libpython_name,
297277
sources=files,
298278
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 [],
302279
)
303280
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-
)
281+
setup(
282+
script_name='setup' + libpython_name,
283+
script_args=args,
284+
name=libpython_name,
285+
version='1.0',
286+
description="Graal Python's C API",
287+
ext_modules=[module],
288+
)
313289

314290
def build_builtin_exts(capi_home):
315291
args = [verbosity, 'build', 'install_lib', '-f', '--install-dir=%s/modules' % capi_home, "clean"]

graalpython/lib-python/3/distutils/sysconfig_graalpython.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def _init_posix():
8282
g['CCSHARED'] = "-fPIC"
8383
g['LDSHARED_LINUX'] = "%s -shared -fPIC" % sys.__graal_get_toolchain_path('CC')
8484
if darwin_native:
85-
capi_home = sys.graal_python_capi_home
86-
g['LDSHARED'] = g['LDSHARED_LINUX'] + " -L" + capi_home + " -lpython." + so_abi + " -Wl,-rpath," + capi_home
85+
g['LDSHARED'] = g['LDSHARED_LINUX'] + " -Wl,-undefined,dynamic_lookup"
8786
else:
8887
g['LDSHARED'] = g['LDSHARED_LINUX']
8988
g['SOABI'] = so_abi

0 commit comments

Comments
 (0)