Skip to content

Commit

Permalink
Skip test_embeddable if compiler cannot be initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 11, 2025
1 parent 3111e37 commit 7166a09
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Tests/test_image_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ def test_embeddable(self) -> None:

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:
home = sys.prefix.replace("\\", "\\\\")
fh.write(
Expand Down Expand Up @@ -305,13 +317,6 @@ def test_embeddable(self) -> None:
"""
)

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"])
compiler.link_executable(objects, "embed_pil")

Expand Down

0 comments on commit 7166a09

Please sign in to comment.