@@ -4,7 +4,7 @@ load("//python:repositories.bzl", "STANDALONE_INTERPRETER_FILENAME")
4
4
load ("//python/pip_install:repositories.bzl" , "all_requirements" )
5
5
load ("//python/pip_install/private:srcs.bzl" , "PIP_INSTALL_PY_SRCS" )
6
6
7
- CFLAGS = "CFLAGS "
7
+ CPPFLAGS = "CPPFLAGS "
8
8
9
9
def _construct_pypath (rctx ):
10
10
"""Helper function to construct a PYTHONPATH.
@@ -65,7 +65,7 @@ def _resolve_python_interpreter(rctx):
65
65
return python_interpreter
66
66
67
67
def _maybe_set_xcode_location_cflags (rctx , environment ):
68
- """Patch environment with CFLAGS of xcode sdk location.
68
+ """Patch environment with CPPFLAGS of xcode sdk location.
69
69
70
70
Figure out if this interpreter target comes from rules_python, and patch the xcode sdk location if so.
71
71
Pip won't be able to compile c extensions from sdists with the pre built python distributions from indygreg
@@ -74,7 +74,8 @@ def _maybe_set_xcode_location_cflags(rctx, environment):
74
74
if (
75
75
rctx .os .name .lower ().startswith ("mac os" ) and
76
76
rctx .attr .python_interpreter_target != None and
77
- rctx .path (Label ("@{}//:{}" .format (rctx .attr .python_interpreter_target .workspace_name , STANDALONE_INTERPRETER_FILENAME )))
77
+ rctx .path (Label ("@{}//:{}" .format (rctx .attr .python_interpreter_target .workspace_name , STANDALONE_INTERPRETER_FILENAME ))) and
78
+ not environment .get (CPPFLAGS )
78
79
):
79
80
xcode_sdk_location = rctx .execute (["xcode-select" , "-p" ])
80
81
if xcode_sdk_location .return_code == 0 :
@@ -83,7 +84,7 @@ def _maybe_set_xcode_location_cflags(rctx, environment):
83
84
# This is a full xcode installation somewhere like /Applications/Xcode13.0.app/Contents/Developer
84
85
# so we need to change the path to to the macos specific tools.
85
86
xcode_root = "{}/Platforms/MacOSX.platform/Developer" .format (xcode_root )
86
- environment [CFLAGS ] = "-isysroot {}/SDKs/MacOSX.sdk" .format (xcode_root )
87
+ environment [CPPFLAGS ] = "-isysroot {}/SDKs/MacOSX.sdk" .format (xcode_root )
87
88
88
89
def _parse_optional_attrs (rctx , args ):
89
90
"""Helper function to parse common attributes of pip_repository and whl_library repository rules.
0 commit comments