@@ -282,10 +282,14 @@ def from_interpreter(cls) -> BuildDetailsV1:
282282 LIBRARY = sysconfig .get_config_var ('LIBRARY' )
283283 PY3LIBRARY = sysconfig .get_config_var ('PY3LIBRARY' )
284284 LIBPYTHON = sysconfig .get_config_var ('LIBPYTHON' )
285+ STATIC_LIBPYTHON = sysconfig .get_config_var ('STATIC_LIBPYTHON' )
286+ PYTHONFRAMEWORK = sysconfig .get_config_var ('PYTHONFRAMEWORK' )
285287
286288 LIBDIR = pathlib .Path (sysconfig .get_config_var ('LIBDIR' ))
287289 LIBPC = pathlib .Path (sysconfig .get_config_var ('LIBPC' ))
290+ LIBPL = pathlib .Path (sysconfig .get_config_var ('LIBPL' ))
288291 INCLUDEPY = pathlib .Path (sysconfig .get_config_var ('INCLUDEPY' ))
292+ PYTHONFRAMEWORKPREFIX = pathlib .Path (sysconfig .get_config_var ('PYTHONFRAMEWORKPREFIX' ))
289293
290294 interpreter_name = 'python' + sysconfig .get_config_var ('LDVERSION' ) + sysconfig .get_config_var ('EXE' )
291295
@@ -314,19 +318,31 @@ def from_interpreter(cls) -> BuildDetailsV1:
314318 headers = INCLUDEPY ,
315319 )
316320
321+ print (f'{ PYTHONFRAMEWORK = !r} ' )
322+
317323 if os .name == 'posix' :
318324 # On POSIX, LIBRARY is always the static library, while LDLIBRARY is the
319325 # dynamic library if enabled, otherwise it's the static library.
320326 # If LIBRARY != LDLIBRARY, support for the dynamic library is enabled.
321327 has_dynamic_library = LDLIBRARY != LIBRARY
322- has_static_library = sysconfig .get_config_var ('STATIC_LIBPYTHON' )
328+ # macOS framework builds don't install the static library (see libainstall).
329+ has_static_library = STATIC_LIBPYTHON and not PYTHONFRAMEWORK
330+ # The static library is only installed into LIBDIR when it is also
331+ # LDLIBRARY; otherwise it is only installed into LIBPL.
332+ static_library_dir = LIBPL if has_dynamic_library else LIBDIR
333+ # In framework builds, LDLIBRARY is the path of the framework library
334+ # relative to PYTHONFRAMEWORKPREFIX (e.g.
335+ # Python.framework/Versions/3.X/Python), not a file in LIBDIR.
336+ dynamic_library_dir = PYTHONFRAMEWORKPREFIX if PYTHONFRAMEWORK else LIBDIR
323337 elif os .name == 'nt' :
324338 # Windows can only use a dynamic library or a static library.
325339 # If it's using a dynamic library, sys.dllhandle will be set.
326340 # Static builds on Windows are not really well supported, though.
327341 # More context: https://github.com/python/cpython/issues/110234
328342 has_dynamic_library = hasattr (sys , 'dllhandle' )
329343 has_static_library = not has_dynamic_library
344+ static_library_dir = LIBDIR
345+ dynamic_library_dir = LIBDIR
330346 else :
331347 raise NotADirectoryError (f'Unknown platform: { os .name } ' )
332348
@@ -347,18 +363,18 @@ def from_interpreter(cls) -> BuildDetailsV1:
347363 data .abi .stable_abi_suffix = suffix
348364 break
349365
350- data .libpython .dynamic = LIBDIR / LDLIBRARY
366+ data .libpython .dynamic = dynamic_library_dir / LDLIBRARY
351367 # FIXME: Not sure if windows has a different dll for the stable ABI, and
352368 # even if it does, currently we don't have a way to get its name.
353369 if PY3LIBRARY :
354- data .libpython .dynamic_stableabi = LIBDIR / PY3LIBRARY
370+ data .libpython .dynamic_stableabi = dynamic_library_dir / PY3LIBRARY
355371
356372 # Os POSIX, this is defined by the LIBPYTHON Makefile variable not being
357373 # empty. On Windows, don't link extensions — LIBPYTHON won't be defined,
358374 data .libpython .link_extensions = bool (LIBPYTHON )
359375
360376 if has_static_library :
361- data .libpython .static = LIBDIR / LIBRARY
377+ data .libpython .static = static_library_dir / LIBRARY
362378
363379 if LIBPC :
364380 data .c_api .pkgconfig_path = LIBPC
0 commit comments