Skip to content

Commit

Permalink
re-organize py venv and use a bazel toolchain rule to specifiy expect…
Browse files Browse the repository at this point in the history
…ed py path
  • Loading branch information
dayfine committed May 4, 2020
1 parent 9b98869 commit 1097784
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.direnv
.venv
11 changes: 2 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ commands:
steps:
- attach_workspace:
at: *workspace_location
- run:
name: pwd
command: |
pwd

# Install python as the bazel image is used instead of python image.
install_python:
Expand All @@ -43,11 +39,8 @@ commands:
- run:
name: Activate virtual environment
command: |
python3.8 -m venv env --without-pip
source env/bin/activate
pwd
ls
which python3
python3.8 -m venv .venv --without-pip
source .venv/bin/activate
# Initializes the CI environment by setting up common environment variables.
init_environment:
Expand Down
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Envrionment setup for local developmeent using direnv.

source secrets.rc

# https://github.com/direnv/direnv/wiki/Python
export VIRTUAL_ENV=.venv
layout python-venv python3.8

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ celerybeat.pid

# Environments
.env
.envrc
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
.direnv
secrets.rc

# Spyder project settings
.spyderproject
Expand Down
18 changes: 18 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair")

py_runtime(
name = "python-3.8",
interpreter = ".venv/bin/python3.8",
python_version = "PY3",
)

py_runtime_pair(
name = "py_runtime_pair",
py3_runtime = ":python-3.8",
)

toolchain(
name = "py_toolchain",
toolchain = ":py_runtime_pair",
toolchain_type = "@rules_python//python:toolchain_type",
)
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ http_archive(
url = "https://github.com/dillon-giacoppo/rules_python_external/archive/v{version}.zip".format(version = rules_python_external_version),
)

register_toolchains("//:py_toolchain")

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
Expand Down Expand Up @@ -75,5 +77,7 @@ load("@rules_python_external//:defs.bzl", "pip_install")

pip_install(
name = "py_deps",
# TODO(dayfine): this should not be necesasry.
python_interpreter = "/usr/bin/python3.8",
requirements = "//:requirements.txt",
)
1 change: 1 addition & 0 deletions xlab/data/scripts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ py_binary(
"//xlab/util/status:errors",
requirement("absl-py"),
requirement("protobuf"),
],
)

0 comments on commit 1097784

Please sign in to comment.