Skip to content

Commit fb470ee

Browse files
committed
python: Fix using library from PEP 739 without pkg-config
Fix the `find_libpy()` PEP 739 branch to handle the full path correctly. Meson's `find_library()` function accepts only the "bare" name, while `build-details.json` provides the full path to the library. The previous code would just extract the basename, but it would still contain the library prefix and suffix. Rather than trying to hack around that, just use the full path directly.
1 parent 1ee4e9b commit fb470ee

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

mesonbuild/dependencies/python.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,26 @@ def find_libpy(self, environment: 'Environment') -> None:
295295
path = self.build_config['libpython'].get('dynamic')
296296
if not path:
297297
raise DependencyException('Python does not provide a dynamic libpython library')
298-
libdirs = [os.path.dirname(path)]
299-
libname = os.path.basename(path)
300-
else:
301-
if self.is_pypy:
302-
if self.major_version == 3:
303-
libname = 'pypy3-c'
304-
else:
305-
libname = 'pypy-c'
306-
libdir = os.path.join(self.variables.get('base'), 'bin')
307-
libdirs = [libdir]
298+
if not os.path.isfile(path):
299+
raise DependencyException('Python dynamic library does not exist or is not a file')
300+
self.link_args = [path]
301+
self.is_found = True
302+
return
303+
304+
if self.is_pypy:
305+
if self.major_version == 3:
306+
libname = 'pypy3-c'
308307
else:
309-
libname = f'python{self.version}'
310-
if 'DEBUG_EXT' in self.variables:
311-
libname += self.variables['DEBUG_EXT']
312-
if 'ABIFLAGS' in self.variables:
313-
libname += self.variables['ABIFLAGS']
314-
libdirs = []
308+
libname = 'pypy-c'
309+
libdir = os.path.join(self.variables.get('base'), 'bin')
310+
libdirs = [libdir]
311+
else:
312+
libname = f'python{self.version}'
313+
if 'DEBUG_EXT' in self.variables:
314+
libname += self.variables['DEBUG_EXT']
315+
if 'ABIFLAGS' in self.variables:
316+
libname += self.variables['ABIFLAGS']
317+
libdirs = []
315318

316319
largs = self.clib_compiler.find_library(libname, environment, libdirs)
317320
if largs is not None:

0 commit comments

Comments
 (0)