Skip to content
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
8 changes: 8 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,11 @@ oci.pull(
tag = "latest",
)
use_repo(oci, "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8")

# For tests
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")

local_repository(
name = "rpy610_test",
path = "./py/tests/rpy610/subrepo",
)
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,9 @@ oci_pull(
load("@container_structure_test//:repositories.bzl", "container_structure_test_register_toolchain")

container_structure_test_register_toolchain(name = "cst")

# For tests
local_repository(
name = "rpy610_test",
path = "./py/tests/rpy610/subrepo",
)
13 changes: 0 additions & 13 deletions py/tests/py-internal-venv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,3 @@ py_venv_test(
"@pypi_cowsay//:pkg",
],
)

py_venv_test(
name = "test_env_vars",
srcs = ["test_env_vars.py"],
env = {
"ONE": "un",
"TWO": "deux",
"RULEDIR": "$(RULEDIR)",
"LOCATION": "$(location :test_env_vars.py)",
"DEFINE": "$(SOME_VAR)",
},
main = "test_env_vars.py",
)
2 changes: 1 addition & 1 deletion py/tests/py-venv-standalone-interpreter/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex

ROOT="$(dirname $0)"

"$ROOT"/.ex/bin/python --help
"$ROOT"/.ex/bin/python --help >/dev/null 2>&1

if [ "Hello, world!" != "$($ROOT/.ex/bin/python -c 'from ex import hello; print(hello())')" ]; then
exit 1
Expand Down
6 changes: 3 additions & 3 deletions py/tests/py_venv_conflict/test_import_roots.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def tree(dir_path: Path, prefix: str=''):
print(sys.prefix)

import conflict
print("conflict.__file__", conflict.__file__)
print(conflict.__file__)
assert conflict.__file__.startswith(sys.prefix)

import noconflict
print("noconflict.__file__", noconflict.__file__)
print(noconflict.__file__)
assert noconflict.__file__.startswith(sys.prefix)

import py_venv_conflict.lib as srclib
print("srclib.__file__", srclib.__file__)
print(srclib.__file__)
assert not srclib.__file__.startswith(sys.prefix)
16 changes: 16 additions & 0 deletions py/tests/rpy610/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//py/private/py_venv:defs.bzl", "py_venv_test")

py_venv_test(
name = "test",
srcs = [
"test.py",
],
imports = [
".",
],
main = "test.py",
deps = [
"@pypi_cowsay//:pkg",
"@rpy610_test//:foo",
],
)
10 changes: 10 additions & 0 deletions py/tests/rpy610/subrepo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@aspect_rules_py//py:defs.bzl", "py_library")

py_library(
name = "foo",
srcs = [
"foo.py",
],
imports = ["."],
visibility = ["//visibility:public"],
)
Empty file.
2 changes: 2 additions & 0 deletions py/tests/rpy610/subrepo/foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def foo(x):
return x ** 3.15
32 changes: 32 additions & 0 deletions py/tests/rpy610/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import os
import sys
import site

print("---")
print("__file__:", __file__)
print("sys.prefix:", sys.prefix)
print("sys.executable:", sys.executable)
print("site.PREFIXES:")
for p in site.PREFIXES:
print(" -", p)

# The virtualenv module should have already been loaded at interpreter startup
assert "_virtualenv" in sys.modules

# Note that we can't assume that a `.runfiles` tree has been created as CI may
# use a different layout.

# The virtualenv changes the sys.prefix, which should be in our runfiles
assert sys.prefix.endswith("/py/tests/rpy610/.test")

# That prefix should also be "the" prefix per site.PREFIXES
assert site.PREFIXES[0].endswith("/py/tests/rpy610/.test")

# The virtualenv also changes the sys.executable (if we've done this right)
assert sys.executable.find("/py/tests/rpy610/.test/bin/python") != -1

# aspect-build/rules_py#610, these imports aren't quite right
import foo
print(foo.__file__)
Loading