diff --git a/CHANGELOG.md b/CHANGELOG.md index 029de8ae11..9e59564b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ A brief description of the categories of changes: * (gazelle): Update error messages when unable to resolve a dependency to be more human-friendly. ### Fixed +* (whl_library): Remove `--no-index` and add `--no-build-isolation` to the + `pip install` command when installing a wheel from a local file, which happens + when `experimental_index_url` flag is used. * (bzlmod) get the path to the host python interpreter in a way that results in platform non-dependent hashes in the lock file when the requirement markers need to be evaluated. diff --git a/examples/bzlmod/MODULE.bazel.lock b/examples/bzlmod/MODULE.bazel.lock index e542f43b0a..4deef01be4 100644 --- a/examples/bzlmod/MODULE.bazel.lock +++ b/examples/bzlmod/MODULE.bazel.lock @@ -1231,7 +1231,7 @@ }, "@@rules_python~//python/extensions:pip.bzl%pip": { "general": { - "bzlTransitiveDigest": "iJtgc0fsxL6yWzjazyklge5csIWtbgQ8+wgW8P4jfL0=", + "bzlTransitiveDigest": "eWzi4IV0AzQ+cpVkMkdU/wOc7BUQdo0hAAQcCh8C4uU=", "usagesDigest": "MChlcSw99EuW3K7OOoMcXQIdcJnEh6YmfyjJm+9mxIg=", "recordedFileInputs": { "@@other_module~//requirements_lock_3_11.txt": "a7d0061366569043d5efcf80e34a32c732679367cb3c831c4cdc606adc36d314", @@ -6140,7 +6140,7 @@ }, "@@rules_python~//python/private/pypi:pip.bzl%pip_internal": { "general": { - "bzlTransitiveDigest": "vTGpUAA3aBLYLx1iJ020kpJsuvO9GLbl11swsDXNKRI=", + "bzlTransitiveDigest": "RyEJxfGmNQVzqInjjGrR29yqfFPKe9DKgODI1mxd8wA=", "usagesDigest": "Y8ihY+R57BAFhalrVLVdJFrpwlbsiKz9JPJ99ljF7HA=", "recordedFileInputs": { "@@rules_python~//tools/publish/requirements.txt": "031e35d03dde03ae6305fe4b3d1f58ad7bdad857379752deede0f93649991b8a", diff --git a/python/private/pypi/whl_library.bzl b/python/private/pypi/whl_library.bzl index 2300eb3598..5b14151be6 100644 --- a/python/private/pypi/whl_library.bzl +++ b/python/private/pypi/whl_library.bzl @@ -227,8 +227,10 @@ def _whl_library_impl(rctx): whl_path = rctx.path(rctx.attr.filename) else: # It is an sdist and we need to tell PyPI to use a file in this directory - # and not use any indexes. - extra_pip_args.extend(["--no-index", "--find-links", "."]) + # and, allow getting build dependencies from PYTHONPATH, which we + # setup in this repository rule, but still download any necessary + # build deps from PyPI (e.g. `flit_core`) if they are missing. + extra_pip_args.extend(["--no-build-isolation", "--find-links", "."]) args = _parse_optional_attrs(rctx, args, extra_pip_args) diff --git a/tests/pypi/evaluate_markers/BUILD.bazel b/tests/pypi/evaluate_markers/BUILD.bazel deleted file mode 100644 index aba9264953..0000000000 --- a/tests/pypi/evaluate_markers/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("@dev_pip//:requirements.bzl", "all_whl_requirements") - -build_test( - name = "all_dev_wheels", - targets = all_whl_requirements, -) diff --git a/tests/pypi/integration/BUILD.bazel b/tests/pypi/integration/BUILD.bazel new file mode 100644 index 0000000000..f846bfb124 --- /dev/null +++ b/tests/pypi/integration/BUILD.bazel @@ -0,0 +1,20 @@ +load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@dev_pip//:requirements.bzl", "all_requirements") +load(":transitions.bzl", "transition_rule") + +build_test( + name = "all_requirements_build_test", + targets = all_requirements, +) + +# Rule that transitions dependencies to be built from sdist +transition_rule( + name = "all_requirements_from_sdist", + testonly = True, + deps = all_requirements, +) + +build_test( + name = "all_requirements_from_sdist_build_test", + targets = ["all_requirements_from_sdist"], +) diff --git a/tests/pypi/integration/transitions.bzl b/tests/pypi/integration/transitions.bzl new file mode 100644 index 0000000000..b121446bb0 --- /dev/null +++ b/tests/pypi/integration/transitions.bzl @@ -0,0 +1,24 @@ +""" Define a custom transition that sets the pip_whl flag to no """ + +def _flag_transition_impl(_settings, _ctx): + return {"//python/config_settings:pip_whl": "no"} + +flag_transition = transition( + implementation = _flag_transition_impl, + inputs = [], + outputs = ["//python/config_settings:pip_whl"], +) + +# Define a rule that applies the transition to dependencies +def _transition_rule_impl(_ctx): + return [DefaultInfo()] + +transition_rule = rule( + implementation = _transition_rule_impl, + attrs = { + "deps": attr.label_list(cfg = flag_transition), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, +)