Skip to content

Commit 8e50128

Browse files
committed
feat: add bzlmod and use macro_tmpl for expansion in pip_repository
1 parent 1af3809 commit 8e50128

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

python/pip_install/pip_repository.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ def _pip_repository_bzlmod_impl(rctx):
379379
rctx.file("BUILD.bazel", build_contents)
380380
rctx.template("requirements.bzl", rctx.attr._template, substitutions = {
381381
"%%ALL_REQUIREMENTS%%": _format_repr_list([
382-
"@{}//{}".format(repo_name, p) if rctx.attr.incompatible_generate_aliases else "@{}_{}//:pkg".format(rctx.attr.name, p)
382+
macro_tmpl.format(p, "pkg")
383383
for p in bzl_packages
384384
]),
385385
"%%ALL_WHL_REQUIREMENTS%%": _format_repr_list([
386-
"@{}//{}:whl".format(repo_name, p) if rctx.attr.incompatible_generate_aliases else "@{}_{}//:whl".format(rctx.attr.name, p)
386+
macro_tmpl.format(p, "whl")
387387
for p in bzl_packages
388388
]),
389389
"%%MACRO_TMPL%%": macro_tmpl,

tests/pip_parse/MODULE.bazel

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module(
2+
name = "example_bzlmod",
3+
version = "0.0.0",
4+
compatibility_level = 1,
5+
)
6+
7+
bazel_dep(name = "bazel_skylib", version = "1.3.0")
8+
bazel_dep(name = "rules_python", version = "0.0.0")
9+
local_path_override(
10+
module_name = "rules_python",
11+
path = "../..",
12+
)
13+
14+
python = use_extension("@rules_python//python:extensions.bzl", "python")
15+
python.toolchain(
16+
name = "python3_9",
17+
configure_coverage_tool = True,
18+
python_version = "3.9",
19+
)
20+
use_repo(
21+
python,
22+
"python3_9",
23+
"python3_9_host_interpreter",
24+
"python3_9_toolchains",
25+
)
26+
27+
register_toolchains(
28+
"@python3_9_toolchains//:all",
29+
)
30+
31+
pip = use_extension("@rules_python//python:extensions.bzl", "pip")
32+
pip.parse(
33+
name = "pypi",
34+
python_interpreter_target = "@python3_9_host_interpreter//:python",
35+
requirements_lock = "//:requirements_lock.txt",
36+
requirements_windows = "//:requirements_windows.txt",
37+
)
38+
pip.parse(
39+
name = "pypi_aliases",
40+
incompatible_generate_aliases = True,
41+
python_interpreter_target = "@python3_9_host_interpreter//:python",
42+
requirements_lock = "//:requirements_lock.txt",
43+
requirements_windows = "//:requirements_windows.txt",
44+
)
45+
use_repo(pip, "pypi", "pypi_aliases")

tests/pip_parse/WORKSPACE.bzlmod

Whitespace-only changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy