15
15
"""This file contains repository rules and macros to support toolchain registration.
16
16
"""
17
17
18
- load ("//python:versions.bzl" , "FREETHREADED" , "PLATFORMS" )
18
+ load ("//python:versions.bzl" , "FREETHREADED" , "INSTALL_ONLY" , " PLATFORMS" )
19
19
load (":auth.bzl" , "get_auth" )
20
20
load (":repo_utils.bzl" , "REPO_DEBUG_ENV_VAR" , "repo_utils" )
21
21
load (":text_util.bzl" , "render" )
@@ -72,51 +72,13 @@ def _python_repository_impl(rctx):
72
72
urls = rctx .attr .urls or [rctx .attr .url ]
73
73
auth = get_auth (rctx , urls )
74
74
75
- if release_filename . endswith ( ".zst" ) :
76
- rctx .download (
75
+ if INSTALL_ONLY in release_filename :
76
+ rctx .download_and_extract (
77
77
url = urls ,
78
78
sha256 = rctx .attr .sha256 ,
79
- output = release_filename ,
79
+ stripPrefix = rctx . attr . strip_prefix ,
80
80
auth = auth ,
81
81
)
82
- unzstd = rctx .which ("unzstd" )
83
- if not unzstd :
84
- url = rctx .attr .zstd_url .format (version = rctx .attr .zstd_version )
85
- rctx .download_and_extract (
86
- url = url ,
87
- sha256 = rctx .attr .zstd_sha256 ,
88
- auth = auth ,
89
- )
90
- working_directory = "zstd-{version}" .format (version = rctx .attr .zstd_version )
91
-
92
- repo_utils .execute_checked (
93
- rctx ,
94
- op = "python_repository.MakeZstd" ,
95
- arguments = [
96
- repo_utils .which_checked (rctx , "make" ),
97
- "--jobs=4" ,
98
- ],
99
- timeout = 600 ,
100
- quiet = True ,
101
- working_directory = working_directory ,
102
- logger = logger ,
103
- )
104
- zstd = "{working_directory}/zstd" .format (working_directory = working_directory )
105
- unzstd = "./unzstd"
106
- rctx .symlink (zstd , unzstd )
107
-
108
- repo_utils .execute_checked (
109
- rctx ,
110
- op = "python_repository.ExtractRuntime" ,
111
- arguments = [
112
- repo_utils .which_checked (rctx , "tar" ),
113
- "--extract" ,
114
- "--strip-components=2" ,
115
- "--use-compress-program={unzstd}" .format (unzstd = unzstd ),
116
- "--file={}" .format (release_filename ),
117
- ],
118
- logger = logger ,
119
- )
120
82
else :
121
83
rctx .download_and_extract (
122
84
url = urls ,
@@ -125,6 +87,12 @@ def _python_repository_impl(rctx):
125
87
auth = auth ,
126
88
)
127
89
90
+ # Strip the things that are not present in the INSTALL_ONLY builds
91
+ # NOTE: if the dirs are not present, we will not fail here
92
+ rctx .delete ("python/build" )
93
+ rctx .delete ("python/licenses" )
94
+ rctx .delete ("python/PYTHON.json" )
95
+
128
96
patches = rctx .attr .patches
129
97
if patches :
130
98
for patch in patches :
@@ -378,15 +346,6 @@ function defaults (e.g. `single_version_override` for `MODULE.bazel` files.
378
346
"urls" : attr .string_list (
379
347
doc = "The URL of the interpreter to download. Exactly one of url and urls must be set." ,
380
348
),
381
- "zstd_sha256" : attr .string (
382
- default = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0" ,
383
- ),
384
- "zstd_url" : attr .string (
385
- default = "https://github.com/facebook/zstd/releases/download/v{version}/zstd-{version}.tar.gz" ,
386
- ),
387
- "zstd_version" : attr .string (
388
- default = "1.5.2" ,
389
- ),
390
349
"_rule_name" : attr .string (default = "python_repository" ),
391
350
},
392
351
environ = [REPO_DEBUG_ENV_VAR ],
0 commit comments