Skip to content

Commit a20f320

Browse files
committed
Improved variable name: VIRTUALENVWRAPPER_ENV_BIN_DIR instead of script_folder and is_msys instead of msys.
1 parent e6c11fd commit a20f320

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

virtualenvwrapper.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ then
5757
fi
5858

5959
# Define script folder depending on the platorm (Win32/Unix)
60-
script_folder="bin"
60+
VIRTUALENVWRAPPER_ENV_BIN_DIR="bin"
6161
if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ]
6262
then
6363
# Only assign this for msys, cygwin use standard Unix paths
6464
# and its own python installation
65-
script_folder="Scripts"
65+
VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts"
6666
fi
6767

6868
virtualenvwrapper_derive_workon_home() {
@@ -286,7 +286,7 @@ virtualenvwrapper_show_workon_options () {
286286
# NOTE: DO NOT use ls here because colorized versions spew control characters
287287
# into the output list.
288288
# echo seems a little faster than find, even with -depth 3.
289-
(cd "$WORKON_HOME"; for f in */$script_folder/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$')
289+
(cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$')
290290

291291
# (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort
292292
}
@@ -366,7 +366,7 @@ workon () {
366366
virtualenvwrapper_verify_workon_home || return 1
367367
virtualenvwrapper_verify_workon_environment $env_name || return 1
368368

369-
activate="$WORKON_HOME/$env_name/$script_folder/activate"
369+
activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate"
370370
if [ ! -f "$activate" ]
371371
then
372372
echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2
@@ -399,7 +399,7 @@ workon () {
399399
# any settings made by the local postactivate first.
400400
virtualenvwrapper_run_hook "pre_deactivate"
401401
402-
env_postdeactivate_hook="$VIRTUAL_ENV/$script_folder/postdeactivate"
402+
env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate"
403403
old_env=$(basename "$VIRTUAL_ENV")
404404
405405
# Call the original function.
@@ -598,7 +598,7 @@ cpvirtualenv() {
598598
fi
599599

600600
\cp -r "$source_env" "$target_env"
601-
for script in $( \ls $target_env/$script_folder/* )
601+
for script in $( \ls $target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/* )
602602
do
603603
newscript="$script-new"
604604
\sed "s|$source_env|$target_env|g" < "$script" > "$newscript"
@@ -607,7 +607,7 @@ cpvirtualenv() {
607607
done
608608

609609
virtualenv "$target_env" --relocatable
610-
\sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$script_folder/activate"
610+
\sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate"
611611

612612
(cd "$WORKON_HOME" && (
613613
virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env";

virtualenvwrapper/user_scripts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# Are we running under msys
2222
if sys.platform == 'win32' and os.environ.get('OS') == 'Windows_NT' and os.environ.get('MSYSTEM') == 'MINGW32':
23-
msys = True
23+
is_msys = True
2424
script_folder = 'Scripts'
2525
else:
2626
script_folder = 'bin'
@@ -31,7 +31,7 @@ def run_script(script_path, *args):
3131
"""
3232
if os.path.exists(script_path):
3333
cmd = [script_path] + list(args)
34-
if msys:
34+
if is_msys:
3535
cmd = [get_path(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd
3636
log.debug('running %s', str(cmd))
3737
try:
@@ -246,12 +246,12 @@ def get_env_details(args):
246246
def get_path(*args):
247247
'''
248248
Get a full path from args.
249-
Path separator is determined according to the os and the shell and allow to use msys.
249+
Path separator is determined according to the os and the shell and allow to use is_msys.
250250
Variables and user are expanded during the process.
251251
'''
252252
path = os.path.expanduser(os.path.expandvars(os.path.join(*args)))
253-
if msys:
254-
# MSYS accept unix or Win32 and sometimes it conduce to mixed style paths
253+
if is_msys:
254+
# MSYS accept unix or Win32 and sometimes it drives to mixed style paths
255255
if re.match(r'^/[a-zA-Z](/|^)', path):
256256
# msys path could starts with '/c/'-form drive letter
257257
path = ''.join((path[1],':',path[2:]))

0 commit comments

Comments
 (0)