Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56751e4

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 e01d4f1 commit 56751e4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

setupext.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,19 @@ 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 for var, value in (
614+
(var, sysconfig.get_config_var(var))
615+
for var in ["CC", "CFLAGS", "CXX", "CXXFLAGS", "LD",
616+
"LDFLAGS"]
617+
) if value
618+
},
617619
}
620+
env["CFLAGS"] = env.get("CFLAGS", "") + " -fPIC"
618621
subprocess.check_call(
619622
["./configure", "--with-zlib=no", "--with-bzip2=no",
620623
"--with-png=no", "--with-harfbuzz=no", "--enable-static",
@@ -668,6 +671,7 @@ def do_custom_build(self, env):
668671
f.truncate()
669672
f.write(vcxproj)
670673

674+
cc = get_ccompiler()
671675
cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
672676
cc.spawn(["msbuild", str(sln_path),
673677
"/t:Clean;Build",

0 commit comments

Comments
 (0)