1515"""This file contains repository rules and macros to support toolchain registration.
1616"""
1717
18- load ("//python:versions.bzl" , "FREETHREADED" , "PLATFORMS" )
18+ load ("//python:versions.bzl" , "FREETHREADED" , "INSTALL_ONLY" , " PLATFORMS" )
1919load (":auth.bzl" , "get_auth" )
2020load (":repo_utils.bzl" , "REPO_DEBUG_ENV_VAR" , "repo_utils" )
2121load (":text_util.bzl" , "render" )
@@ -72,51 +72,13 @@ def _python_repository_impl(rctx):
7272 urls = rctx .attr .urls or [rctx .attr .url ]
7373 auth = get_auth (rctx , urls )
7474
75- if release_filename . endswith ( ".zst" ) :
76- rctx .download (
75+ if INSTALL_ONLY in release_filename :
76+ rctx .download_and_extract (
7777 url = urls ,
7878 sha256 = rctx .attr .sha256 ,
79- output = release_filename ,
79+ stripPrefix = rctx . attr . strip_prefix ,
8080 auth = auth ,
8181 )
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- )
12082 else :
12183 rctx .download_and_extract (
12284 url = urls ,
@@ -125,6 +87,12 @@ def _python_repository_impl(rctx):
12587 auth = auth ,
12688 )
12789
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+
12896 patches = rctx .attr .patches
12997 if patches :
13098 for patch in patches :
@@ -378,15 +346,6 @@ function defaults (e.g. `single_version_override` for `MODULE.bazel` files.
378346 "urls" : attr .string_list (
379347 doc = "The URL of the interpreter to download. Exactly one of url and urls must be set." ,
380348 ),
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- ),
390349 "_rule_name" : attr .string (default = "python_repository" ),
391350 },
392351 environ = [REPO_DEBUG_ENV_VAR ],
0 commit comments