From d5d49c700ce3bc291ad9a7b498c95ec437673cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Reni=C3=A9?= Date: Tue, 23 Sep 2014 17:30:40 +0200 Subject: [PATCH] Support virtualenvs created with --python=/usr/bin/pythonX.Y --- virtualenv_tools.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/virtualenv_tools.py b/virtualenv_tools.py index f5671c1..da10407 100644 --- a/virtualenv_tools.py +++ b/virtualenv_tools.py @@ -26,6 +26,7 @@ ] _pybin_match = re.compile(r'^python\d+\.\d+$') _activation_path_re = re.compile(r'^(?:set -gx |setenv |)VIRTUAL_ENV[ =]"(.*?)"\s*$') +_shebang_bin_re = re.compile(r'.*/bin/python(\d+(\.\d+)?)?$') def update_activation_script(script_filename, new_path): @@ -65,11 +66,13 @@ def update_script(script_filename, new_path): if not args: return - if not args[0].endswith('/bin/python') or \ + if not _shebang_bin_re.match(args[0]) or \ '/usr/bin/env python' in args[0]: return - new_bin = os.path.join(new_path, 'bin', 'python') + python = args[0].split('/')[-1] + + new_bin = os.path.join(new_path, 'bin', python) if new_bin == args[0]: return