Skip to content

Commit e8643c3

Browse files
author
Kiko Fernandez Reyes
committed
creates a virtual environment for encorec
the idea is to create a virtual environment similar to what you can expect in virtualenv (python) and/or rbenv (ruby). At the moment it just sets the encore compiler to the right path. Therefore, forking and having multiple copies of the repo with multiple compilers is easy to handle. Steps involved: 1. go to the encore compiler fork you would like to activate 2. source activate 3. from this terminal, you can compile any encore program and it will safely use the encore compiler that you jut activated. missing features: - no real dependency management yet, so no need to create new folder
1 parent 816e03e commit e8643c3

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

activate

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
# reset old environment variables
6+
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
7+
PATH="$_OLD_VIRTUAL_PATH"
8+
export PATH
9+
unset _OLD_VIRTUAL_PATH
10+
fi
11+
if [ -n "$_OLD_VIRTUAL_ENCORECHOME" ] ; then
12+
ENCORECHOME="$_OLD_VIRTUAL_ENCORECHOME"
13+
export ENCORECHOME
14+
unset _OLD_VIRTUAL_ENCORECHOME
15+
fi
16+
17+
# This should detect bash and zsh, which have a hash command that must
18+
# be called to get it to forget past commands. Without forgetting
19+
# past commands the $PATH changes we made may not be respected
20+
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
21+
hash -r 2>/dev/null
22+
fi
23+
24+
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
25+
PS1="$_OLD_VIRTUAL_PS1"
26+
export PS1
27+
unset _OLD_VIRTUAL_PS1
28+
fi
29+
30+
unset ENCOREC_VIRTUAL_ENV
31+
if [ ! "$1" = "nondestructive" ] ; then
32+
# Self destruct!
33+
unset -f deactivate
34+
fi
35+
}
36+
37+
# unset irrelevant variables
38+
deactivate nondestructive
39+
40+
ENCOREC_VIRTUAL_ENV=$(pwd)
41+
export ENCOREC_VIRTUAL_ENV
42+
43+
_OLD_VIRTUAL_PATH="$PATH"
44+
PATH="$ENCOREC_VIRTUAL_ENV/release:$PATH"
45+
export PATH
46+
47+
# unset ENCORECHOME if set
48+
# this will fail if ENCORECHOME is set to the empty string (which is bad anyway)
49+
# could use `if (set -u; : $ENCORECHOME) ;` in bash
50+
if [ -n "$ENCORECHOME" ] ; then
51+
_OLD_VIRTUAL_ENCORECHOME="$ENCORECHOME"
52+
unset ENCORECHOME
53+
fi
54+
55+
if [ -z "$ENCOREC_VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
56+
_OLD_VIRTUAL_PS1="$PS1"
57+
if [ "x" != x ] ; then
58+
PS1="$PS1"
59+
else
60+
if [ "`basename \"$ENCOREC_VIRTUAL_ENV\"`" = "__" ] ; then
61+
# special case for Aspen magic directories
62+
# see http://www.zetadev.com/software/aspen/
63+
PS1="[`basename \`dirname \"$ENCOREC_VIRTUAL_ENV\"\``] $PS1"
64+
else
65+
PS1="(`basename \"$ENCOREC_VIRTUAL_ENV\"`)$PS1"
66+
fi
67+
fi
68+
export PS1
69+
fi
70+
71+
# This should detect bash and zsh, which have a hash command that must
72+
# be called to get it to forget past commands. Without forgetting
73+
# past commands the $PATH changes we made may not be respected
74+
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
75+
hash -r 2>/dev/null
76+
fi

0 commit comments

Comments
 (0)