Skip to content

Commit ae6b7fd

Browse files
committed
Ensure *full* compiler config is passed to FreeType
Using just `CC` from the `distutils` compiler can break universal2 wheels on macOS, but passing all compiler and linker settings appears to work. Plus grabbing this information from `sysconfig` is better than hacking the `distutils` compiler into working.
1 parent d81e8bf commit ae6b7fd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

setupext.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,18 @@ def do_custom_build(self, env):
605605
if (src_path / 'objs' / '.libs' / libfreetype).is_file():
606606
return # Bail out because we have already built FreeType.
607607

608-
cc = get_ccompiler()
609-
610608
print(f"Building freetype in {src_path}")
611609
if sys.platform != 'win32': # compilation on non-windows
612610
env = {
613611
**env,
614-
"CC": (shlex.join(cc.compiler) if sys.version_info >= (3, 8)
615-
else " ".join(shlex.quote(x) for x in cc.compiler)),
616-
"CFLAGS": "{} -fPIC".format(env.get("CFLAGS", "")),
612+
**{
613+
var: value
614+
for var, value in sysconfig.get_config_vars().items()
615+
if var in {"CC", "CFLAGS", "CXX", "CXXFLAGS", "LD",
616+
"LDFLAGS"}
617+
},
617618
}
619+
env["CFLAGS"] = env.get("CFLAGS", "") + " -fPIC"
618620
subprocess.check_call(
619621
["./configure", "--with-zlib=no", "--with-bzip2=no",
620622
"--with-png=no", "--with-harfbuzz=no", "--enable-static",
@@ -668,6 +670,7 @@ def do_custom_build(self, env):
668670
f.truncate()
669671
f.write(vcxproj)
670672

673+
cc = get_ccompiler()
671674
cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
672675
cc.spawn(["msbuild", str(sln_path),
673676
"/t:Clean;Build",

0 commit comments

Comments
 (0)