Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
psalaberria002 committed Jun 20, 2024
1 parent 98a19d2 commit 27d840d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ bazel-*

venv/
.venv/

__pycache__
4 changes: 3 additions & 1 deletion examples/typical/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ create_venv(name = "create-venv")
create_venv(
name = "create-venv-custom-destination",
destination_folder = ".venv",
site_packages_extra_files = ["sitecustomize.py"],
site_packages_extra_files = [
"site_packages_extra/sitecustomize.py",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello() -> None:
print("Hello")
12 changes: 12 additions & 0 deletions examples/typical/site_packages_extra/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is loaded by the Python interpreter and can alter the Python module loading process.
# We use it to inject lib/python into our PYTHON_PATH so that we can import modules relative to this directory.
import os
import sys

dirname = os.path.dirname(__file__)
# Add site_packages_extra/lib/python to path so we can import `hello`` without the site_packages_extra.lib.python prefix
sys.path.append(
os.path.abspath(os.path.join(dirname, "../../../../site_packages_extra/lib/python"))
)
# Add repo root to the path
sys.path.append(os.path.abspath(os.path.join(dirname, "../../../..")))
1 change: 0 additions & 1 deletion examples/typical/sitecustomize.py

This file was deleted.

0 comments on commit 27d840d

Please sign in to comment.