Skip to content

Commit 784d292

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). Closes #68528. Signed-off-by: Carlo Cabrera <[email protected]>
1 parent 397f004 commit 784d292

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Formula/[email protected]

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,21 @@ def install
124124
args << "--with-system-ffi"
125125
end
126126

127-
cflags = ["-I#{HOMEBREW_PREFIX}/include"]
128-
ldflags = ["-L#{HOMEBREW_PREFIX}/lib"]
129-
cppflags = ["-I#{HOMEBREW_PREFIX}/include"]
127+
# Python re-uses flags when building native modules.
128+
# Since we don't want native modules prioritizing the brew
129+
# include path, we move them to [C|LD]FLAGS_NODIST.
130+
# Note: Changing CPPFLAGS causes issues with dbm, so we
131+
# leave it as-is.
132+
cflags = []
133+
cflags_nodist = ["-I#{HOMEBREW_PREFIX}/include"]
134+
ldflags = []
135+
ldflags_nodist = ["-L#{HOMEBREW_PREFIX}/lib"]
136+
cppflags = ["-I#{HOMEBREW_PREFIX}/include"]
130137

131138
if MacOS.sdk_path_if_needed
132139
# Help Python's build system (setuptools/pip) to build things on SDK-based systems
133140
# The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
134-
cflags << "-isysroot #{MacOS.sdk_path}" << "-I#{MacOS.sdk_path}/usr/include"
141+
cflags << "-isysroot #{MacOS.sdk_path}"
135142
ldflags << "-isysroot #{MacOS.sdk_path}"
136143
end
137144
# Avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html
@@ -162,7 +169,9 @@ def install
162169
end
163170

164171
args << "CFLAGS=#{cflags.join(" ")}" unless cflags.empty?
172+
args << "CFLAGS_NODIST=#{cflags_nodist.join(" ")}" unless cflags_nodist.empty?
165173
args << "LDFLAGS=#{ldflags.join(" ")}" unless ldflags.empty?
174+
args << "LDFLAGS_NODIST=#{ldflags_nodist.join(" ")}" unless ldflags_nodist.empty?
166175
args << "CPPFLAGS=#{cppflags.join(" ")}" unless cppflags.empty?
167176

168177
system "./configure", *args

0 commit comments

Comments
 (0)