Skip to content

Commit

Permalink
PR updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislovecnm committed Jun 19, 2023
2 parents 18de6f7 + 8fcfb1d commit 76d5d6b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
8 changes: 4 additions & 4 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use_repo(python, "python_3_10", "python_3_9", "python_aliases")

whl_mods = use_extension("@rules_python//python/extensions:whl_mods.bzl", "whl_modifications")
whl_mods.create(
whl_name = "requests",
hub_name = "whl_mods_hub",
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
Expand All @@ -50,10 +48,10 @@ write_file(
)
""",
data = [":generated_file"],
hub_name = "whl_mods_hub",
whl_name = "requests",
)
whl_mods.create(
whl_name = "wheel",
hub_name = "whl_mods_hub",
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
Expand All @@ -70,6 +68,8 @@ write_file(
},
data = [":generated_file"],
data_exclude_glob = ["site-packages/*.dist-info/WHEEL"],
hub_name = "whl_mods_hub",
whl_name = "wheel",
)
use_repo(whl_mods, "whl_mods_hub")

Expand Down
10 changes: 5 additions & 5 deletions examples/bzlmod/pip_repository_annotations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_build_content_and_data(self):
),
)
generated_file = Path(rpath)
self.assertTrue(generated_file.exists(), msg = "{}".format(rpath))
self.assertTrue(generated_file.exists())

content = generated_file.read_text().rstrip()
self.assertEqual(content, "Hello world from build content file")
Expand All @@ -67,7 +67,7 @@ def test_copy_executables(self):
)
)
executable = Path(rpath)
self.assertTrue(executable.exists(), msg = "{}".format(rpath))
self.assertTrue(executable.exists())

proc = subprocess.run(
[sys.executable, str(executable)],
Expand Down Expand Up @@ -98,10 +98,10 @@ def test_data_exclude_glob(self):
# `runfiles.Rlocation` results will be different on this platform vs
# unix platforms. See `@rules_python//python/runfiles` for more details.
if platform.system() == "Windows":
self.assertIsNotNone(metadata_path)
self.assertIsNone(wheel_path)
self.assertTrue(Path(metadata_path).exists())
self.assertFalse(Path(wheel_path).exists())
else:
self.assertTrue(Path(metadata_path).exists(), msg = "{}".format(metadata_path))
self.assertTrue(Path(metadata_path).exists())
self.assertFalse(Path(wheel_path).exists())

def requests_pkg_dir(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions examples/bzlmod/requirements_windows_3_10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# bazel run //:requirements_3_10.update
#
--extra-index-url https://pypi.python.org/simple/

astroid==2.13.5 \
--hash=sha256:6891f444625b6edb2ac798829b689e95297e100ddf89dbed5a8c610e34901501 \
--hash=sha256:df164d5ac811b9f44105a72b8f9d5edfb7b5b2d7e979b04ea377a77b3229114a
Expand Down Expand Up @@ -242,6 +244,10 @@ websockets==11.0.3 \
--hash=sha256:fb06eea71a00a7af0ae6aefbb932fb8a7df3cb390cc217d51a9ad7343de1b8d0 \
--hash=sha256:ffd7dcaf744f25f82190856bc26ed81721508fc5cbf2a330751e135ff1283564
# via -r requirements.in
wheel==0.40.0 \
--hash=sha256:cd1196f3faee2b31968d626e1731c94f99cbdb67cf5a46e4f5656cbee7738873 \
--hash=sha256:d236b20e7cb522daf2390fa84c55eea81c5c30190f90f29ae2ca1ad8355bf247
# via -r requirements.in
wrapt==1.15.0 \
--hash=sha256:02fce1852f755f44f95af51f69d22e45080102e9d00258053b79367d07af39c0 \
--hash=sha256:077ff0d1f9d9e4ce6476c1a924a3332452c1406e59d90a2cf24aeb29eeac9420 \
Expand Down
6 changes: 6 additions & 0 deletions examples/bzlmod/requirements_windows_3_9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# bazel run //:requirements_3_9.update
#
--extra-index-url https://pypi.python.org/simple/

astroid==2.12.13 \
--hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \
--hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7
Expand Down Expand Up @@ -231,6 +233,10 @@ websockets==11.0.3 \
--hash=sha256:fb06eea71a00a7af0ae6aefbb932fb8a7df3cb390cc217d51a9ad7343de1b8d0 \
--hash=sha256:ffd7dcaf744f25f82190856bc26ed81721508fc5cbf2a330751e135ff1283564
# via -r requirements.in
wheel==0.40.0 \
--hash=sha256:cd1196f3faee2b31968d626e1731c94f99cbdb67cf5a46e4f5656cbee7738873 \
--hash=sha256:d236b20e7cb522daf2390fa84c55eea81c5c30190f90f29ae2ca1ad8355bf247
# via -r requirements.in
wrapt==1.14.1 \
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
Expand Down
18 changes: 12 additions & 6 deletions python/extensions/whl_mods.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def _whl_mods_impl(mctx):

whl_modifications = module_extension(
doc = """\
This extension is used to create JSON file that are used when calling wheel_builder.py. These
JSON files contain instructions on how to modify a wheel's project. Each of the attributes
create different modifications based on the type of attribute. Previously to bzlmod these
JSON files where referred to as annotations, and were renamed to whl_modifications in this
extension.
""",
implementation = _whl_mods_impl,
tag_classes = {
Expand All @@ -56,17 +61,17 @@ whl_modifications = module_extension(
doc = """\
(str, optional): path to a BUILD file to add to the generated
`BUILD` file of a package.""",
),
"copy_files": attr.string_dict(
doc = """\
(dict, optional): A mapping of `src` and `out` files for
[@bazel_skylib//rules:copy_file.bzl][cf]""",
),
"copy_executables": attr.string_dict(
doc = """\
(dict, optional): A mapping of `src` and `out` files for
[@bazel_skylib//rules:copy_file.bzl][cf]. Targets generated here will also be flagged as
executable.""",
),
"copy_files": attr.string_dict(
doc = """\
(dict, optional): A mapping of `src` and `out` files for
[@bazel_skylib//rules:copy_file.bzl][cf]""",
),
"data": attr.string_list(
doc = """\
Expand All @@ -91,7 +96,7 @@ otherwise it is best practice to just use one.""",
`py_library` target.""",
),
"whl_name": attr.string(
doc = "The whl name that the modifications are used for",
doc = "The whl name that the modifications are used for.",
mandatory = True,
),
},
Expand All @@ -112,6 +117,7 @@ exports_files(

_whl_mods_repo = repository_rule(
doc = """\
This rule creates json files based on the whl_mods attribute.
""",
implementation = _whl_mods_repo_impl,
attrs = {
Expand Down

0 comments on commit 76d5d6b

Please sign in to comment.