Skip to content

Commit dc50a12

Browse files
committed
fix(pypi): pull fewer wheels
Before this we would pull all of the wheels that the user target configuration would be compatible with and that meant that it was not customizable. This also meant that there were a lot of footguns in the configuration where the select statements were not really foolproof. With this PR we select only those sources that need to be for the declared configurations. Freethreaded support should be done by defining extre freethreaded platforms using the new builder API. Work towards #2747 Work towards #2759 Work towards #2849
1 parent 7fd4baf commit dc50a12

File tree

13 files changed

+620
-517
lines changed

13 files changed

+620
-517
lines changed

MODULE.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
6363
pip.parse(
6464
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
6565
# being able to build sdists for this hub, so explicitly set this to False.
66+
#
67+
# how do we test sdists? Maybe just worth adding a single sdist somewhere?
6668
download_only = False,
6769
experimental_index_url = "https://pypi.org/simple",
6870
hub_name = "rules_python_publish_deps",
@@ -155,22 +157,19 @@ dev_pip = use_extension(
155157
dev_dependency = True,
156158
)
157159
dev_pip.parse(
158-
download_only = True,
159160
experimental_index_url = "https://pypi.org/simple",
160161
hub_name = "dev_pip",
161162
parallel_download = False,
162163
python_version = "3.11",
163164
requirements_lock = "//docs:requirements.txt",
164165
)
165166
dev_pip.parse(
166-
download_only = True,
167167
experimental_index_url = "https://pypi.org/simple",
168168
hub_name = "dev_pip",
169169
python_version = "3.13",
170170
requirements_lock = "//docs:requirements.txt",
171171
)
172172
dev_pip.parse(
173-
download_only = True,
174173
experimental_index_url = "https://pypi.org/simple",
175174
hub_name = "pypiserver",
176175
python_version = "3.11",

examples/bzlmod/MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ pip.whl_mods(
158158
)
159159
use_repo(pip, "whl_mods_hub")
160160

161+
# Because below we are using `windows_aarch64` platform, we have to define various
162+
# properties for it.
163+
pip.default(
164+
arch_name = "aarch64",
165+
config_settings = [
166+
"@platforms//os:windows",
167+
"@platforms//cpu:aarch64",
168+
],
169+
env = {
170+
"platform_version": "0",
171+
},
172+
os_name = "windows",
173+
platform = "windows_aarch64",
174+
platform_tags = ["win_amd64"],
175+
want_abis = [], # default to all ABIs
176+
)
177+
161178
# To fetch pip dependencies, use pip.parse. We can pass in various options,
162179
# but typically we pass requirements and the Python version. The Python
163180
# version must have been configured by a corresponding `python.toolchain()`

python/private/pypi/BUILD.bazel

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ bzl_library(
120120
":whl_config_setting_bzl",
121121
":whl_library_bzl",
122122
":whl_repo_name_bzl",
123-
":whl_target_platforms_bzl",
124123
"//python/private:full_version_bzl",
125124
"//python/private:normalize_name_bzl",
126125
"//python/private:version_bzl",
@@ -209,7 +208,7 @@ bzl_library(
209208
":parse_requirements_txt_bzl",
210209
":pypi_repo_utils_bzl",
211210
":requirements_files_by_platform_bzl",
212-
":whl_target_platforms_bzl",
211+
":select_whl_bzl",
213212
"//python/private:normalize_name_bzl",
214213
"//python/private:repo_utils_bzl",
215214
],
@@ -359,6 +358,15 @@ bzl_library(
359358
],
360359
)
361360

361+
bzl_library(
362+
name = "select_whl_bzl",
363+
srcs = ["select_whl.bzl"],
364+
deps = [
365+
":parse_whl_name_bzl",
366+
"//python/private:version_bzl",
367+
],
368+
)
369+
362370
bzl_library(
363371
name = "simpleapi_download_bzl",
364372
srcs = ["simpleapi_download.bzl"],
@@ -422,5 +430,4 @@ bzl_library(
422430
bzl_library(
423431
name = "whl_target_platforms_bzl",
424432
srcs = ["whl_target_platforms.bzl"],
425-
deps = [":parse_whl_name_bzl"],
426433
)

python/private/pypi/evaluate_markers.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ def evaluate_markers(*, requirements, platforms):
4343
for req_string, platform_strings in requirements.items():
4444
req = requirement(req_string)
4545
for platform_str in platform_strings:
46-
env = platforms.get(platform_str)
47-
if not env:
48-
fail("Please define platform: '{}'".format(platform_str))
46+
plat = platforms.get(platform_str)
47+
if not plat:
48+
continue
4949

50-
if evaluate(req.marker, env = env):
50+
if evaluate(req.marker, env = plat.env):
5151
ret.setdefault(req_string, []).append(platform_str)
5252

5353
return ret

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy