Skip to content

Commit 42085b5

Browse files
aignasrickeylev
andauthored
test(whl_library): test a recent fix for pipstar (#3469)
Test for fix for #3352 implemented in #3468. --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent f9992f7 commit 42085b5

File tree

17 files changed

+77
-1
lines changed

17 files changed

+77
-1
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ use_repo(
242242
"pkgutil_nspkg2",
243243
"rules_python_runtime_env_tc_info",
244244
"somepkg_with_build_files",
245+
"whl_library_extras_direct_dep",
245246
"whl_with_build_files",
246247
)
247248

python/private/internal_dev_deps.bzl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,36 @@ def _internal_dev_deps_impl(mctx):
9191
enable_implicit_namespace_pkgs = False,
9292
)
9393

94+
_whl_library_from_dir(
95+
name = "whl_library_extras_direct_dep",
96+
root = "//tests/pypi/whl_library/testdata/pkg:BUILD.bazel",
97+
output = "pkg-1.0-any-none-any.whl",
98+
requirement = "pkg[optional]",
99+
# The following is necessary to enable pipstar and make tests faster
100+
config_load = "@rules_python//tests/pypi/whl_library/testdata:packages.bzl",
101+
dep_template = "@whl_library_extras_{name}//:{target}",
102+
)
103+
_whl_library_from_dir(
104+
name = "whl_library_extras_optional_dep",
105+
root = "//tests/pypi/whl_library/testdata/optional_dep:BUILD.bazel",
106+
output = "optional_dep-1.0-any-none-any.whl",
107+
requirement = "optional_dep",
108+
# The following is necessary to enable pipstar and make tests faster
109+
config_load = "@rules_python//tests/pypi/whl_library/testdata:packages.bzl",
110+
)
111+
112+
def _whl_library_from_dir(*, name, output, root, **kwargs):
113+
whl_from_dir_repo(
114+
name = "{}_whl".format(name),
115+
root = root,
116+
output = output,
117+
)
118+
whl_library(
119+
name = name,
120+
whl_file = "@{}_whl//:{}".format(name, output),
121+
**kwargs
122+
)
123+
94124
internal_dev_deps = module_extension(
95125
implementation = _internal_dev_deps_impl,
96126
doc = "This extension creates internal rules_python dev dependencies.",

python/private/pypi/whl_library.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _whl_library_impl(rctx):
359359

360360
# also enable pipstar for any whls that are downloaded without `pip`
361361
enable_pipstar = (rp_config.enable_pipstar or whl_path) and rctx.attr.config_load
362-
enable_pipstar_extract = (rp_config.enable_pipstar and rp_config.bazel_8_or_later) and rctx.attr.config_load
362+
enable_pipstar_extract = enable_pipstar and rp_config.bazel_8_or_later
363363

364364
if not whl_path:
365365
if rctx.attr.urls:

tests/pypi/whl_library/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("//python:py_test.bzl", "py_test")
2+
load("//tests/support:support.bzl", "SUPPORTS_BZLMOD_UNIXY")
3+
4+
py_test(
5+
name = "whl_library_extras_test",
6+
srcs = ["whl_library_extras_test.py"],
7+
target_compatible_with = SUPPORTS_BZLMOD_UNIXY,
8+
deps = [
9+
"@whl_library_extras_direct_dep//:pkg",
10+
],
11+
)

tests/pypi/whl_library/testdata/BUILD.bazel

Whitespace-only changes.

tests/pypi/whl_library/testdata/optional_dep/BUILD.bazel

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Name: optional-dep
2+
Version: 1.0

tests/pypi/whl_library/testdata/optional_dep/optional-dep-1.0.dist-info/RECORD

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Wheel-Version: 1.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I_AM_OPTIONAL = True

0 commit comments

Comments
 (0)