Skip to content

Commit

Permalink
Make it easier to use a venv
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Jun 21, 2022
1 parent 2780dfb commit 57769a9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ AnkiDroid/ACRA-INSTALLATION
.DS_Store
.externalNativeBuild
.cxx

# optional symlink to venv
python
17 changes: 5 additions & 12 deletions docs/easy-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,11 @@ Install Python packages
## Using a custom python venv

If you don't want to `pip install protobuf` globally, you can
switch to a venv:

```diff
diff --git a/tools/protoc-gen/protoc-gen.sh b/tools/protoc-gen/protoc-gen.sh
index d4039ec..3ac5d29 100755
--- a/tools/protoc-gen/protoc-gen.sh
+++ b/tools/protoc-gen/protoc-gen.sh
@@ -1,2 +1,3 @@
#!/bin/bash
-./tools/protoc-gen/protoc-gen.py
+
+$HOME/Local/python/misc/bin/python3 ./tools/protoc-gen/protoc-gen.py
symlink the python bin from a venv into `python` at the top of
the project folder:

```
$ ln -sf /path/to/venv/bin/python python
```

## Build
Expand Down
2 changes: 1 addition & 1 deletion rslib-bridge/anki
3 changes: 2 additions & 1 deletion tools/genfluent/genfluent.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

./tools/genfluent/genfluent.py
. tools/setup-python
$PYTHON ./tools/genfluent/genfluent.py
4 changes: 3 additions & 1 deletion tools/protoc-gen/protoc-gen.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
./tools/protoc-gen/protoc-gen.py

. tools/setup-python
$PYTHON ./tools/protoc-gen/protoc-gen.py
11 changes: 11 additions & 0 deletions tools/setup-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#
# If `python` in the project folder exists, use it instead of the global python.
#

if [ -e python ]; then
PYTHON=$(readlink $(pwd)/python)
else
PYTHON=$(which python3)
fi

0 comments on commit 57769a9

Please sign in to comment.