Permalink
Browse files

Relative symlinks for relocatable virtualenv.

  • Loading branch information...
1 parent caf030f commit 70af4315f8e1d6e708cc9d35bb2fd9c88bfc13a7 Alexei Boronine committed Aug 1, 2010
Showing with 15 additions and 12 deletions.
  1. +15 −12 pypyenv
View
27 pypyenv
@@ -8,22 +8,23 @@ import shutil
import stat
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-srcdir = os.path.join(base, "src")
-bindir = os.path.join(base, "bin")
+srcdir = "src"
+bindir = "bin"
binpypy = os.path.join(bindir, "pypy")
-pypydir = os.path.join(base, "pypy")
+pypydir = "pypy"
def install():
+ os.chdir(base)
# Clean up if anything was left over
uninstall()
# Create src directory
if not os.path.exists(srcdir):
- print "creating %s directory" % srcdir
+ print "creating ENV/%s directory" % srcdir
os.mkdir(srcdir)
archive = os.path.join(srcdir, "pypy-1.3-linux.tar.bz2")
# Download archive
if os.path.exists(archive):
- print "using previously downloaded %s" % archive
+ print "using previously downloaded ENV/%s" % archive
else:
print "downloading PyPy"
linux_jit = "http://pypy.org/download/pypy-1.3-linux.tar.bz2"
@@ -46,27 +47,28 @@ def install():
print "copying PyPy directory into root"
shutil.copytree(unpacked, pypydir)
# Install PyPy executable symlink
- print "installing %s symlink" % binpypy
- os.symlink(os.path.join(pypydir, "bin", "pypy"), binpypy)
+ print "installing ENV/%s symlink" % binpypy
+ os.symlink(os.path.join("..", "pypy", "bin", "pypy"), binpypy)
print "giving it execute permissions"
os.chmod(binpypy, stat.S_IXUSR)
# Install site-packages symlink
- pythonsite = os.path.join(base, "lib", "python2.5", "site-packages")
- pypysite = os.path.join(base, "pypy", "site-packages")
+ pythonsite = os.path.join("..", "lib", "python2.5", "site-packages")
+ pypysite = os.path.join("pypy", "site-packages")
+ print "installing ENV/%s symlink" % pypysite
os.symlink(pythonsite, pypysite)
def uninstall():
+ os.chdir(base)
if os.path.exists(binpypy):
- print "deleting %s symlink" % binpypy
+ print "deleting ENV/%s symlink" % binpypy
os.remove(binpypy)
if os.path.exists(pypydir):
- print "deleting %s" % pypydir
+ print "deleting ENV/%s" % pypydir
shutil.rmtree(pypydir)
help_message = """pypyenv install - installs PyPy in this virtualenv
pypyenv uninstall - uninstalls PyPy from this virtualenv"""
-
if __name__ == "__main__":
if len(sys.argv) < 2:
print help_message
@@ -76,3 +78,4 @@ if __name__ == "__main__":
uninstall()
else:
print help_message
+

0 comments on commit 70af431

Please sign in to comment.