Skip to content

Commit 397f004

Browse files
Mitchell Hentgescarlocab
authored andcommitted
[email protected]: adjust flags to avoid package installation breakage
* Mac SDK include paths should be system include path. * The brew include path should only be added for building Python, and shouldn't be re-used after (use FLAG_NODIST).
1 parent 9074829 commit 397f004

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Formula/[email protected]

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class PythonAT38 < Formula
44
url "https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tar.xz"
55
sha256 "ddcc1df16bb5b87aa42ec5d20a5b902f2d088caa269b28e01590f97a798ec50a"
66
license "Python-2.0"
7+
revision 1
78

89
livecheck do
910
url "https://www.python.org/ftp/python/"
@@ -100,19 +101,26 @@ def install
100101
--with-openssl=#{Formula["[email protected]"].opt_prefix}
101102
]
102103

103-
cflags = ["-I#{HOMEBREW_PREFIX}/include"]
104-
ldflags = ["-L#{HOMEBREW_PREFIX}/lib"]
105-
cppflags = ["-I#{HOMEBREW_PREFIX}/include"]
104+
# Python re-uses flags when building native modules.
105+
# Since we don't want native modules prioritizing the brew
106+
# include path, we move them to [C|LD]FLAGS_NODIST.
107+
# Note: Changing CPPFLAGS causes issues with dbm, so we
108+
# leave it as-is.
109+
cflags = []
110+
cflags_nodist = ["-I#{HOMEBREW_PREFIX}/include"]
111+
ldflags = []
112+
ldflags_nodist = ["-L#{HOMEBREW_PREFIX}/lib"]
113+
cppflags = ["-I#{HOMEBREW_PREFIX}/include"]
106114

107115
if MacOS.sdk_path_if_needed
108116
# Help Python's build system (setuptools/pip) to build things on SDK-based systems
109117
# The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
110-
cflags << "-isysroot #{MacOS.sdk_path}" << "-I#{MacOS.sdk_path}/usr/include"
118+
cflags << "-isysroot #{MacOS.sdk_path}"
111119
ldflags << "-isysroot #{MacOS.sdk_path}"
112120
# For the Xlib.h, Python needs this header dir with the system Tk
113121
# Yep, this needs the absolute path where zlib needed a path relative
114122
# to the SDK.
115-
cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
123+
cflags << "-isystem #{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
116124
end
117125
# Avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html
118126
args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
@@ -139,7 +147,9 @@ def install
139147
end
140148

141149
args << "CFLAGS=#{cflags.join(" ")}" unless cflags.empty?
150+
args << "CFLAGS_NODIST=#{cflags_nodist.join(" ")}" unless cflags_nodist.empty?
142151
args << "LDFLAGS=#{ldflags.join(" ")}" unless ldflags.empty?
152+
args << "LDFLAGS_NODIST=#{ldflags_nodist.join(" ")}" unless ldflags_nodist.empty?
143153
args << "CPPFLAGS=#{cppflags.join(" ")}" unless cppflags.empty?
144154

145155
system "./configure", *args

0 commit comments

Comments
 (0)