Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
arcivanov committed Sep 19, 2024
1 parent 7270569 commit 9d3d8a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/integrationtest/python/require_libpython_axle_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,30 @@
from wheel_axle.runtime._common import PLATLIBDIR


def is_enabled_shared():
enable_shared = sysconfig.get_config_var("PY_ENABLE_SHARED") or sysconfig.get_config_var("Py_ENABLE_SHARED")
return enable_shared and int(enable_shared)


class RequireLibPythonAxleTest(InstrumentedAxleTest):
def setUp(self) -> None:
super().setUp()

self.wheel_file = jp(self.test_dir, "test_axle_2_libpython-0.0.1-py3-none-any.whl")

def check_libpython_present(self, lib_dir):
enable_shared = sysconfig.get_config_var("PY_ENABLE_SHARED") or sysconfig.get_config_var("Py_ENABLE_SHARED")
if not enable_shared or not int(enable_shared):
return

in_venv = sys.base_exec_prefix != sys.exec_prefix
is_user_site = lib_dir.startswith(site.USER_SITE)
if in_venv or is_user_site:
self.assertTrue(islink(jp(lib_dir, sysconfig.get_config_var("LDLIBRARY"))))
self.assertTrue(islink(jp(lib_dir, sysconfig.get_config_var("INSTSONAME"))))

@unittest.skipIf(not is_enabled_shared(), "Python isn't compiled with --enable-shared")
def test_install_uninstall(self):
self.install(self.wheel_file)
self.uninstall(self.wheel_file)

@unittest.skipIf(not is_enabled_shared(), "Python isn't compiled with --enable-shared")
def test_verify_install(self):
self.install(self.wheel_file)

Expand Down Expand Up @@ -78,6 +81,7 @@ def test_verify_install(self):

self.assertFalse(exists(dist_info))

@unittest.skipIf(not is_enabled_shared(), "Python isn't compiled with --enable-shared")
@unittest.skipIf(sys.base_prefix != sys.prefix, "no user site available under virtualenv")
def test_verify_user_install(self):
self.install(self.wheel_file, True)
Expand Down
8 changes: 4 additions & 4 deletions src/main/python/wheel_axle/runtime/_libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _install_libpython(self):
if not enable_shared or not int(enable_shared):
message = (
"The distribution {!r} requires dynamic linking to the `libpython` "
"but current instance of CPython was built without `--shared` enabled."
"but current instance of CPython was built without `--enable-shared`."
)
raise InstallationError(
message.format(self.dist_meta.project_name)
Expand All @@ -51,15 +51,15 @@ def _install_libpython(self):

# Find libpython library names and locations
shared_library_path = LIBDIR
all_ld_library_names = list(n for n in (sysconfig.get_config_var("LDLIBRARY"),
sysconfig.get_config_var("INSTSONAME")) if n)
all_ld_library_names = list(set(n for n in (sysconfig.get_config_var("LDLIBRARY"),
sysconfig.get_config_var("INSTSONAME")) if n))

# There are no libraries to link to
if not all_ld_library_names:
message = (
"The distribution {!r} requires dynamic linking to the `libpython` "
"but was unable to find any libraries declared available in the current installation of CPython, "
"even though it was compiled with '--shared'"
"even though it was compiled with '--enable-shared'"
)
raise InstallationError(
message.format(self.dist_meta.project_name)
Expand Down

0 comments on commit 9d3d8a3

Please sign in to comment.