Commit 43d34734 authored by Hanno Schlichting's avatar Hanno Schlichting

Removed virtual-python.py from this distribution and updated documentation to...

Removed virtual-python.py from this distribution and updated documentation to point to the actively maintained virtualenv instead.

--HG--
branch : distribute
extra : rebase_source : accfddb40177f981dbf0e5886039fcb27c1be573
parent a858356a
......@@ -6,6 +6,8 @@ CHANGES
0.6.7
-----
* Removed virtual-python.py from this distribution and updated documentation
to point to the actively maintained virtualenv instead.
* Issue 64: use_setuptools no longer rebuilds the distribute egg every
time it is run
* use_setuptools now properly respects the requested version
......
......@@ -1073,34 +1073,10 @@ system, but don't have root access, you can create your own "virtual"
Python installation, which uses its own library directories and some symlinks
to the site-wide Python.
In the simplest case, your virtual Python installation will live under the
``~/lib/python2.x``, ``~/include/python2.x``, and ``~/bin`` directories. Just
download `virtual-python.py`_ and run it using the site-wide Python. If you
want to customize the location, you can use the ``--prefix`` option to specify
an installation base directory in place of ``~``. (Use ``--help`` to get the
complete list of options.)
.. _virtual-python.py: http://peak.telecommunity.com/dist/virtual-python.py
When you're done, you'll have a ``~/bin/python`` executable that's linked to
the local Python installation and inherits all its current libraries, but which
allows you to add as many new libraries as you want. Simply use this new
Python in place of your system-defined one, and you can modify it as you like
without breaking anything that relies on the system Python. You'll also still
need to follow the standard `installation instructions`_ to install setuptools
and EasyInstall, using your new ``~/bin/python`` executable in place of the
system Python.
Note that if you were previously setting a ``PYTHONPATH`` and/or had other
special configuration options in your ``~/.pydistutils.cfg``, you may need to
remove these settings *before* running ``virtual-python.py``. This is because
your new Python executable will not need *any* custom configuration for the
distutils or EasyInstall; everything will go to the correct ``~/lib`` and
``~/bin`` directories automatically.
You should, however, also make sure that the ``bin`` subdirectory of your
installation prefix (e.g. ``~/bin``) is on your ``PATH``, because that is where
EasyInstall and the distutils will install new Python scripts.
Please refer to the `virtualenv`_ documentation for creating such an
environment.
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
"Traditional" ``PYTHONPATH``-based Installation
......
"""Create a "virtual" Python installation
Based on a script created by Ian Bicking."""
import sys, os, optparse, shutil
join = os.path.join
py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
def mkdir(path):
if not os.path.exists(path):
print 'Creating %s' % path
os.makedirs(path)
else:
if verbose:
print 'Directory %s already exists'
def symlink(src, dest):
if not os.path.exists(dest):
if verbose:
print 'Creating symlink %s' % dest
os.symlink(src, dest)
else:
print 'Symlink %s already exists' % dest
def rmtree(dir):
if os.path.exists(dir):
print 'Deleting tree %s' % dir
shutil.rmtree(dir)
else:
if verbose:
print 'Do not need to delete %s; already gone' % dir
def make_exe(fn):
if os.name == 'posix':
oldmode = os.stat(fn).st_mode & 07777
newmode = (oldmode | 0555) & 07777
os.chmod(fn, newmode)
if verbose:
print 'Changed mode of %s to %s' % (fn, oct(newmode))
def main():
if os.name != 'posix':
print "This script only works on Unix-like platforms, sorry."
return
parser = optparse.OptionParser()
parser.add_option('-v', '--verbose', action='count', dest='verbose',
default=0, help="Increase verbosity")
parser.add_option('--prefix', dest="prefix", default='~',
help="The base directory to install to (default ~)")
parser.add_option('--clear', dest='clear', action='store_true',
help="Clear out the non-root install and start from scratch")
parser.add_option('--no-site-packages', dest='no_site_packages',
action='store_true',
help="Don't copy the contents of the global site-packages dir to the "
"non-root site-packages")
options, args = parser.parse_args()
global verbose
home_dir = os.path.expanduser(options.prefix)
lib_dir = join(home_dir, 'lib', py_version)
inc_dir = join(home_dir, 'include', py_version)
bin_dir = join(home_dir, 'bin')
if sys.executable.startswith(bin_dir):
print 'Please use the *system* python to run this script'
return
verbose = options.verbose
assert not args, "No arguments allowed"
if options.clear:
rmtree(lib_dir)
rmtree(inc_dir)
print 'Not deleting', bin_dir
prefix = sys.prefix
mkdir(lib_dir)
stdlib_dir = join(prefix, 'lib', py_version)
for fn in os.listdir(stdlib_dir):
if fn != 'site-packages':
symlink(join(stdlib_dir, fn), join(lib_dir, fn))
mkdir(join(lib_dir, 'site-packages'))
if not options.no_site_packages:
for fn in os.listdir(join(stdlib_dir, 'site-packages')):
symlink(join(stdlib_dir, 'site-packages', fn),
join(lib_dir, 'site-packages', fn))
mkdir(inc_dir)
stdinc_dir = join(prefix, 'include', py_version)
for fn in os.listdir(stdinc_dir):
symlink(join(stdinc_dir, fn), join(inc_dir, fn))
if sys.exec_prefix != sys.prefix:
exec_dir = join(sys.exec_prefix, 'lib', py_version)
for fn in os.listdir(exec_dir):
symlink(join(exec_dir, fn), join(lib_dir, fn))
mkdir(bin_dir)
print 'Copying %s to %s' % (sys.executable, bin_dir)
py_executable = join(bin_dir, 'python')
if sys.executable != py_executable:
shutil.copyfile(sys.executable, py_executable)
make_exe(py_executable)
pydistutils = os.path.expanduser('~/.pydistutils.cfg')
if os.path.exists(pydistutils):
print 'Please make sure you remove any previous custom paths from'
print "your", pydistutils, "file."
print "You're now ready to download distribute_setup.py, and run"
print py_executable, "distribute_setup.py"
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment