Skip to content

Commit f97e2e0

Browse files
authored
fix(venv_link): Correct name argument (#601)
Fixes #598. --- ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: yes Repairs an issue which caused the `venv_name` parameter to produce errors. ### Test plan - Tests added
1 parent e5168aa commit f97e2e0

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

docs/venv.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/use_release/minimal_download_test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ fi
100100
# Smoke test
101101
bazel "--output_base=$OUTPUT_BASE" test --test_output=streamed //...
102102

103+
#############
104+
# Smoke test py_venv_link
105+
bazel "--output_base=$OUTPUT_BASE" run //src:venv
106+
if ! [ -L ./.venv_named ]; then
107+
>&2 echo "ERROR: The named venv target failed to respect venv_name"
108+
exit 1
109+
fi
110+
103111
#############
104112
# Demonstrate that as configured we're fully on prebuilt toolchains even for crossbuilds
105113
OUTPUT_BASE=$(mktemp -d)

e2e/use_release/src/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_test")
1+
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_test", "py_venv")
22

33
py_binary(
44
name = "main",
@@ -9,6 +9,15 @@ py_binary(
99
main = "__main__.py",
1010
)
1111

12+
py_venv(
13+
name = "venv",
14+
srcs = [
15+
"__init__.py",
16+
"__main__.py",
17+
],
18+
venv_name = ".venv_named",
19+
)
20+
1221
py_test(
1322
name = "test",
1423
srcs = ["my_test.py"],

py/private/py_venv/py_venv.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,15 @@ py_venv = _wrap_with_debug(_py_venv)
378378
py_venv_binary = _wrap_with_debug(_py_venv_binary)
379379
py_venv_test = _wrap_with_debug(_py_venv_test)
380380

381-
def py_venv_link(venv_name = None, **kwargs):
381+
def py_venv_link(venv_name = None, srcs = [], **kwargs):
382382
"""Build a Python virtual environment and produce a script to link it into the build directory."""
383383

384384
# Note that the binary is already wrapped with debug
385385
link_script = str(Label("//py/private/py_venv:link.py"))
386386
kwargs["debug"] = select({Label(":debug_build"): True, "//conditions:default": False})
387387
py_venv_binary(
388-
args = [] + (["--venv-name=" + venv_name] if venv_name else []),
388+
args = [] + (["--name=" + venv_name] if venv_name else []),
389389
main = link_script,
390-
srcs = [link_script],
390+
srcs = srcs + [link_script],
391391
**kwargs
392392
)

0 commit comments

Comments
 (0)