@@ -27,8 +27,8 @@ load("//python/private:normalize_name.bzl", "normalize_name")
27
27
load ("//python/private:parse_whl_name.bzl" , "parse_whl_name" )
28
28
load ("//python/private:patch_whl.bzl" , "patch_whl" )
29
29
load ("//python/private:render_pkg_aliases.bzl" , "render_pkg_aliases" )
30
+ load ("//python/private:repo_utils.bzl" , "REPO_DEBUG_ENV_VAR" , "repo_utils" )
30
31
load ("//python/private:toolchains_repo.bzl" , "get_host_os_arch" )
31
- load ("//python/private:which.bzl" , "which_with_fail" )
32
32
load ("//python/private:whl_target_platforms.bzl" , "whl_target_platforms" )
33
33
34
34
CPPFLAGS = "CPPFLAGS"
@@ -115,7 +115,11 @@ def _get_xcode_location_cflags(rctx):
115
115
if not rctx .os .name .lower ().startswith ("mac os" ):
116
116
return []
117
117
118
- xcode_sdk_location = rctx .execute ([which_with_fail ("xcode-select" , rctx ), "--print-path" ])
118
+ xcode_sdk_location = repo_utils .execute_unchecked (
119
+ rctx ,
120
+ op = "GetXcodeLocation" ,
121
+ arguments = [repo_utils .which_checked (rctx , "xcode-select" ), "--print-path" ],
122
+ )
119
123
if xcode_sdk_location .return_code != 0 :
120
124
return []
121
125
@@ -144,14 +148,16 @@ def _get_toolchain_unix_cflags(rctx, python_interpreter):
144
148
if not is_standalone_interpreter (rctx , python_interpreter ):
145
149
return []
146
150
147
- er = rctx .execute ([
148
- python_interpreter ,
149
- "-c" ,
150
- "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}', end='')" ,
151
- ])
152
- if er .return_code != 0 :
153
- fail ("could not get python version from interpreter (status {}): {}" .format (er .return_code , er .stderr ))
154
- _python_version = er .stdout
151
+ stdout = repo_utils .execute_checked_stdout (
152
+ rctx ,
153
+ op = "GetPythonVersionForUnixCflags" ,
154
+ arguments = [
155
+ python_interpreter ,
156
+ "-c" ,
157
+ "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}', end='')" ,
158
+ ],
159
+ )
160
+ _python_version = stdout
155
161
include_path = "{}/include/python{}" .format (
156
162
python_interpreter .dirname ,
157
163
_python_version ,
@@ -406,6 +412,7 @@ def _pip_repository_impl(rctx):
406
412
407
413
common_env = [
408
414
"RULES_PYTHON_PIP_ISOLATED" ,
415
+ REPO_DEBUG_ENV_VAR ,
409
416
]
410
417
411
418
common_attrs = {
@@ -526,7 +533,7 @@ is one of `linux`, `osx`, `windows` and arch is one of `x86_64`, `x86_32`,
526
533
527
534
You can also target a specific Python version by using `cp3<minor_version>_<os>_<arch>`.
528
535
If multiple python versions are specified as target platforms, then select statements
529
- of the `lib` and `whl` targets will include usage of version aware toolchain config
536
+ of the `lib` and `whl` targets will include usage of version aware toolchain config
530
537
settings like `@rules_python//python/config_settings:is_python_3.y`.
531
538
532
539
Special values: `host` (for generating deps for the host platform only) and
@@ -753,28 +760,14 @@ def _whl_library_impl(rctx):
753
760
# Manually construct the PYTHONPATH since we cannot use the toolchain here
754
761
environment = _create_repository_execution_environment (rctx , python_interpreter )
755
762
756
- result = rctx .execute (
757
- args ,
763
+ repo_utils .execute_checked (
764
+ rctx ,
765
+ op = "whl_library.ResolveRequirement({}, {})" .format (rctx .attr .name , rctx .attr .requirement ),
766
+ arguments = args ,
758
767
environment = environment ,
759
768
quiet = rctx .attr .quiet ,
760
769
timeout = rctx .attr .timeout ,
761
770
)
762
- if result .return_code :
763
- fail ((
764
- "whl_library '{name}' wheel_installer failed:\n " +
765
- " command: {cmd}\n " +
766
- " environment:\n {env}\n " +
767
- " return code: {return_code}\n " +
768
- "===== stdout start ====\n {stdout}\n ===== stdout end===\n " +
769
- "===== stderr start ====\n {stderr}\n ===== stderr end===\n "
770
- ).format (
771
- name = rctx .attr .name ,
772
- cmd = " " .join ([str (a ) for a in args ]),
773
- env = "\n " .join (["{}={}" .format (k , v ) for k , v in environment .items ()]),
774
- return_code = result .return_code ,
775
- stdout = result .stdout ,
776
- stderr = result .stderr ,
777
- ))
778
771
779
772
whl_path = rctx .path (json .decode (rctx .read ("whl_file.json" ))["whl_file" ])
780
773
if not rctx .delete ("whl_file.json" ):
@@ -807,8 +800,10 @@ def _whl_library_impl(rctx):
807
800
for p in whl_target_platforms (parsed_whl .platform_tag )
808
801
]
809
802
810
- result = rctx .execute (
811
- args + [
803
+ repo_utils .execute_checked (
804
+ rctx ,
805
+ op = "whl_library.ExtractWheel({}, {})" .format (rctx .attr .name , whl_path ),
806
+ arguments = args + [
812
807
"--whl-file" ,
813
808
whl_path ,
814
809
] + ["--platform={}" .format (p ) for p in target_platforms ],
@@ -817,9 +812,6 @@ def _whl_library_impl(rctx):
817
812
timeout = rctx .attr .timeout ,
818
813
)
819
814
820
- if result .return_code :
821
- fail ("whl_library %s failed: %s (%s) error code: '%s'" % (rctx .attr .name , result .stdout , result .stderr , result .return_code ))
822
-
823
815
metadata = json .decode (rctx .read ("metadata.json" ))
824
816
rctx .delete ("metadata.json" )
825
817
0 commit comments