Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(whl_library): remove --no-index and add --no-build-isolation when build sdist #2126

Merged
merged 6 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions python/private/pypi/whl_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 0 additions & 7 deletions tests/pypi/evaluate_markers/BUILD.bazel

This file was deleted.

20 changes: 20 additions & 0 deletions tests/pypi/integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
24 changes: 24 additions & 0 deletions tests/pypi/integration/transitions.bzl
Original file line number Diff line number Diff line change
@@ -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",
),
},
)