Skip to content

Commit e8be419

Browse files
author
Cerem Cem ASLAN
committed
updated virtual environment documentation
1 parent 79d0a8f commit e8be419

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CONFIG := $(DIR)../dcs-modules.txt
66
.PHONY: test-es6-compat update-deps update-app-version
77

88
# Check if we are in a VIRTUAL_ENV:
9+
# the `NODE_VIRTUAL_ENV` variable is set by nodeenv after activating the environment.
910
__c:
1011
$(if $(NODE_VIRTUAL_ENV),,$($(warning ************ WARNING: NOT INSIDE A VIRTUAL ENV ************)))
1112

doc/using-virtual-environment.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,30 @@
2525

2626
4. Install the Scada.js dependencies:
2727

28+
$ ./venv
2829
(scadajs1) $ make install-deps CONF=../dcs-modules.txt
2930
30-
5. Optional: Move your nodeenv to a central location and use it between projects:
31-
32-
dest=$HOME/nodeenv/scadajs-1 # or anywhere you like
33-
mv nodeenv/ $dest
34-
echo "export SCADAJS_1_ENV='$dest'" >> ~/.bashrc
31+
# Using virtual environment from within Tmux
3532

36-
> Next time you can use: `./scada.js/venv`
33+
1. (Optional) Set the `SCADAJS_VENV_PATH` variable for the `TARGET_TMUX_SESSION`:
3734

38-
# Preparing Tmux
35+
```bash
36+
tmux setenv -t ${TARGET_TMUX_SESSION} 'SCADAJS_VENV_PATH' /path/to/somewhere/scadajs1
37+
```
3938

40-
1. Add the following in your `~/.profile` (or `~/.bashrc`):
39+
2. On every new pane, manually activate your virtual environment by:
4140

4241
```bash
43-
# For Tmux VirtualEnv support
44-
tmux_get_var(){
45-
local key=$1
46-
[[ -n "$TMUX" ]] && tmux showenv | awk -F= -v key="$key" '$1==key {print $2}'
47-
}
48-
49-
# activate the virtual environment if it is declared
50-
venv=$(tmux_get_var "VIRTUAL_ENV")
51-
if [ -n "$venv" ]; then
52-
source $venv/bin/activate;
53-
fi
42+
$ ./scada.js/venv
43+
(scadajs1) $
5444
```
5545

56-
2. Set the `VIRTUAL_ENV` variable for the target session:
46+
By setting the Tmux's `SCADAJS_VENV_PATH` variable, `./scada.js/venv` script uses this
47+
virtual environment by default. If you want to start a different virtual environment in your
48+
new pane:
5749

5850
```bash
59-
tmux setenv -t ${SESSION_NAME} 'VIRTUAL_ENV' /path/to/virtualenv/
51+
$ ./scada.js/venv /path/to/your/other/virtual-environment
52+
(something) $
6053
```
6154

0 commit comments

Comments
 (0)