Browse files

Minor changes following on from pull request 401

- Documentation updates
- Tidy up fixup_scripts
- Make the activate_this code for relocatable scripts work on Python 3
  • Loading branch information...
pfmoore committed Mar 8, 2013
1 parent 8a36309 commit 602bdbcd34823d2973a644a4c6867922c1e9380b
Showing with 16 additions and 5 deletions.
  1. +1 −0 AUTHORS.txt
  2. +12 −0 docs/index.rst
  3. +3 −5
@@ -38,6 +38,7 @@ Ethan Jucovy
Gabriel de Perthuis
Gunnlaugur Thor Briem
Greg Haskins
+Jason Penney
Jason R. Coombs
Jeff Hammel
Jeremy Orem
@@ -405,6 +405,12 @@ Making Environments Relocatable
Note: this option is somewhat experimental, and there are probably
caveats that have not yet been identified.
+.. warning::
+ The ``--relocatable`` option currently has a number of issues,
+ and is not guaranteed to work in all circumstances. It is possible
+ that the option will be deprecated in a future version of ``virtualenv``.
Normally environments are tied to a specific path. That means that
you cannot move an environment around or copy it to another computer.
You can fix up an environment to make it relocatable with the
@@ -417,6 +423,12 @@ use relative paths, and will change all the scripts to use ````
instead of using the location of the Python interpreter to select the
+**Note:** scripts which have been made relocatable will only work if
+the virtualenv is activated, specifically the python executable from
+the virtualenv must be the first one on the system PATH. Also note that
+the activate scripts are not currently made relocatable by
+``virtualenv --relocatable``.
**Note:** you must run this after you've installed *any* packages into
the environment. If you make an environment relocatable, then
install a new package, you must run ``virtualenv --relocatable``
@@ -1687,16 +1687,14 @@ def make_environment_relocatable(home_dir):
'The environment doesn\'t have a file %s -- please re-run virtualenv '
'on this environment to update it' % activate_this)
- fixup_scripts(home_dir)
+ fixup_scripts(home_dir, bin_dir)
## FIXME: need to fix up distutils.cfg
OK_ABS_SCRIPTS = ['python', 'python%s' % sys.version[:3],
'activate', 'activate.bat', '']
-def fixup_scripts(home_dir):
- home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir)
- # new_shebang_args = (env_cmd, ver_suffix, bin_suffix)
+def fixup_scripts(home_dir, bin_dir):
if is_win:
new_shebang_args = (
'%s /c' % os.path.normcase(os.environ.get('COMSPEC', 'cmd.exe')),
@@ -1749,7 +1747,7 @@ def fixup_scripts(home_dir):
def relative_script(lines):
"Return a script that'll work in a relocatable environment."
- activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), ''); execfile(activate_this, dict(__file__=activate_this)); del os, activate_this"
+ activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), ''); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this"
# Find the last future statement in the script. If we insert the activation
# line before a future statement, Python will raise a SyntaxError.
activate_at = None

0 comments on commit 602bdbc

Please sign in to comment.