Merge pull request #8686 from radarhere/test_embeddable_wheels

This commit is contained in:
Hugo van Kemenade 2025-01-13 21:21:06 +02:00 committed by GitHub
commit f521a4be7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -278,6 +278,18 @@ class TestEmbeddable:
from setuptools.command import build_ext from setuptools.command import build_ext
compiler = getattr(build_ext, "new_compiler")()
compiler.add_include_dir(sysconfig.get_config_var("INCLUDEPY"))
libdir = sysconfig.get_config_var("LIBDIR") or sysconfig.get_config_var(
"INCLUDEPY"
).replace("include", "libs")
compiler.add_library_dir(libdir)
try:
compiler.initialize()
except Exception:
pytest.skip("Compiler could not be initialized")
with open("embed_pil.c", "w", encoding="utf-8") as fh: with open("embed_pil.c", "w", encoding="utf-8") as fh:
home = sys.prefix.replace("\\", "\\\\") home = sys.prefix.replace("\\", "\\\\")
fh.write( fh.write(
@ -305,13 +317,6 @@ int main(int argc, char* argv[])
""" """
) )
compiler = getattr(build_ext, "new_compiler")()
compiler.add_include_dir(sysconfig.get_config_var("INCLUDEPY"))
libdir = sysconfig.get_config_var("LIBDIR") or sysconfig.get_config_var(
"INCLUDEPY"
).replace("include", "libs")
compiler.add_library_dir(libdir)
objects = compiler.compile(["embed_pil.c"]) objects = compiler.compile(["embed_pil.c"])
compiler.link_executable(objects, "embed_pil") compiler.link_executable(objects, "embed_pil")