Skip to content

Commit 2bc3577

Browse files
authored
fix(pypi): mark the extension reproducible (#2730)
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 #2434 Created #2731 to leverage the bazel feature to write immutable facts to the lock file once it becomes available.
1 parent 69a9920 commit 2bc3577

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
419419
extra_aliases = {}
420420
whl_libraries = {}
421421

422-
is_reproducible = True
423-
424422
for mod in module_ctx.modules:
425423
for pip_attr in mod.tags.parse:
426424
hub_name = pip_attr.hub_name
@@ -458,7 +456,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
458456

459457
get_index_urls = None
460458
if pip_attr.experimental_index_url:
461-
is_reproducible = False
462459
skip_sources = [
463460
normalize_name(s)
464461
for s in pip_attr.simpleapi_skip
@@ -543,7 +540,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
543540
k: dict(sorted(args.items()))
544541
for k, args in sorted(whl_libraries.items())
545542
},
546-
is_reproducible = is_reproducible,
547543
)
548544

549545
def _pip_impl(module_ctx):
@@ -640,7 +636,7 @@ def _pip_impl(module_ctx):
640636
# In order to be able to dogfood the `experimental_index_url` feature before it gets
641637
# stabilized, we have created the `_pip_non_reproducible` function, that will result
642638
# in extra entries in the lock file.
643-
return module_ctx.extension_metadata(reproducible = mods.is_reproducible)
639+
return module_ctx.extension_metadata(reproducible = True)
644640
else:
645641
return None
646642

tests/pypi/extension/extension_tests.bzl

Lines changed: 0 additions & 7 deletions
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": {
@@ -278,7 +275,6 @@ torch==2.4.1 ; platform_machine != 'x86_64' \
278275
},
279276
)
280277

281-
pypi.is_reproducible().equals(True)
282278
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
283279
pypi.hub_group_map().contains_exactly({"pypi": {}})
284280
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -404,7 +400,6 @@ torch==2.4.1+cpu ; platform_machine == 'x86_64' \
404400
simpleapi_download = mocksimpleapi_download,
405401
)
406402

407-
pypi.is_reproducible().equals(False)
408403
pypi.exposed_packages().contains_exactly({"pypi": ["torch"]})
409404
pypi.hub_group_map().contains_exactly({"pypi": {}})
410405
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -535,7 +530,6 @@ simple==0.0.3 \
535530
},
536531
)
537532

538-
pypi.is_reproducible().equals(True)
539533
pypi.exposed_packages().contains_exactly({"pypi": ["simple"]})
540534
pypi.hub_group_map().contains_exactly({"pypi": {}})
541535
pypi.hub_whl_map().contains_exactly({"pypi": {
@@ -673,7 +667,6 @@ git_dep @ git+https://git.server/repo/project@deadbeefdeadbeef
673667
simpleapi_download = mocksimpleapi_download,
674668
)
675669

676-
pypi.is_reproducible().equals(False)
677670
pypi.exposed_packages().contains_exactly({"pypi": [
678671
"direct_sdist_without_sha",
679672
"direct_without_sha",

0 commit comments

Comments
 (0)