Skip to content

Commit 1ab491e

Browse files
committed
fix(pypi): mark the extension reproducible
This will remove the merge conflicts and improve the usability when the `MODULE.bazel.lock` is used together with `rules_python`. This means that the lock file will not be used to read the `URL` and `sha256` values for the Python sources when the `experimental_index_url` is used, but the idea is that that information will be kept in repo cache. Fixes bazel-contrib#2434
1 parent 67e233f commit 1ab491e

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Unreleased changes template.
6969
* (toolchains) Remove all but `3.8.20` versions of the Python `3.8` interpreter who has
7070
reached EOL. If users still need other versions of the `3.8` interpreter, please supply
7171
the URLs manually {bzl:ob}`python.toolchain` or {bzl:obj}`python_register_toolchains` calls.
72+
* (pypi) The PyPI extension will no longer write the lock file entries as the
73+
extension has been marked reproducible.
74+
Fixes [#2434](https://github.com/bazel-contrib/rules_python/issues/2434).
7275

7376
[20250317]: https://github.com/astral-sh/python-build-standalone/releases/tag/20250317
7477

python/private/pypi/extension.bzl

+1-5
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
437437
extra_aliases = {}
438438
whl_libraries = {}
439439

440-
is_reproducible = True
441-
442440
for mod in module_ctx.modules:
443441
for pip_attr in mod.tags.parse:
444442
hub_name = pip_attr.hub_name
@@ -476,7 +474,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
476474

477475
get_index_urls = None
478476
if pip_attr.experimental_index_url:
479-
is_reproducible = False
480477
get_index_urls = lambda ctx, distributions: simpleapi_download(
481478
ctx,
482479
attr = struct(
@@ -553,7 +550,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
553550
k: dict(sorted(args.items()))
554551
for k, args in sorted(whl_libraries.items())
555552
},
556-
is_reproducible = is_reproducible,
557553
)
558554

559555
def _pip_impl(module_ctx):
@@ -650,7 +646,7 @@ def _pip_impl(module_ctx):
650646
# In order to be able to dogfood the `experimental_index_url` feature before it gets
651647
# stabilized, we have created the `_pip_non_reproducible` function, that will result
652648
# in extra entries in the lock file.
653-
return module_ctx.extension_metadata(reproducible = mods.is_reproducible)
649+
return module_ctx.extension_metadata(reproducible = True)
654650
else:
655651
return None
656652

tests/pypi/extension/extension_tests.bzl

-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _parse_modules(env, **kwargs):
6464
return env.expect.that_struct(
6565
parse_modules(**kwargs),
6666
attrs = dict(
67-
is_reproducible = subjects.bool,
6867
exposed_packages = subjects.dict,
6968
hub_group_map = subjects.dict,
7069
hub_whl_map = subjects.dict,
@@ -160,7 +159,6 @@ def _test_simple(env):
160159
},
161160
)
162161

163-
pypi.is_reproducible().equals(True)
164162
pypi.exposed_packages().contains_exactly({"pypi": ["simple"]})
165163
pypi.hub_group_map().contains_exactly({"pypi": {}})
166164
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -209,7 +207,6 @@ def _test_simple_multiple_requirements(env):
209207
},
210208
)
211209

212-
pypi.is_reproducible().equals(True)
213210
pypi.exposed_packages().contains_exactly({"pypi": ["simple"]})
214211
pypi.hub_group_map().contains_exactly({"pypi": {}})
215212
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -286,7 +283,6 @@ torch==2.4.1 ; platform_machine != 'x86_64' \
286283
},
287284
)
288285

289-
pypi.is_reproducible().equals(True)
290286
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
291287
pypi.hub_group_map().contains_exactly({"pypi": {}})
292288
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -421,7 +417,6 @@ torch==2.4.1+cpu ; platform_machine == 'x86_64' \
421417
simpleapi_download = mocksimpleapi_download,
422418
)
423419

424-
pypi.is_reproducible().equals(False)
425420
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
426421
pypi.hub_group_map().contains_exactly({"pypi": {}})
427422
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -552,7 +547,6 @@ simple==0.0.3 \
552547
},
553548
)
554549

555-
pypi.is_reproducible().equals(True)
556550
pypi.exposed_packages().contains_exactly({"pypi": ["simple"]})
557551
pypi.hub_group_map().contains_exactly({"pypi": {}})
558552
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -669,7 +663,6 @@ some_pkg==0.0.1
669663
simpleapi_download = mocksimpleapi_download,
670664
)
671665

672-
pypi.is_reproducible().equals(False)
673666
pypi.exposed_packages().contains_exactly({"pypi": ["simple", "some_pkg"]})
674667
pypi.hub_group_map().contains_exactly({"pypi": {}})
675668
pypi.hub_whl_map().contains_exactly({

0 commit comments

Comments
 (0)