mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Applied patch from ticket 35, adds option to allow access to global site-packages if a virtual environment is to be created
This commit is contained in:
parent
6cbbde2ec1
commit
a8177a9027
|
@ -25,6 +25,9 @@ hg tip
|
|||
* Fix the way bundle components are unpacked and moved around, to make
|
||||
bundles work.
|
||||
|
||||
* Adds ``-s`` option to allow the access to the global site-packages if a
|
||||
virtualenv is to be created.
|
||||
|
||||
0.3.1
|
||||
-----
|
||||
|
||||
|
|
17
pip.py
17
pip.py
|
@ -158,6 +158,13 @@ parser.add_option(
|
|||
metavar='DIR',
|
||||
help='virtualenv environment to run pip in (either give the '
|
||||
'interpreter or the environment base directory)')
|
||||
parser.add_option(
|
||||
'-s', '--enable-site-packages',
|
||||
dest='site_packages',
|
||||
action='store_true',
|
||||
help='Include site-packages in virtualenv if one is to be '
|
||||
'created. Ignored if --environment is not used or '
|
||||
'the virtualenv already exists.')
|
||||
parser.add_option(
|
||||
'-v', '--verbose',
|
||||
dest='verbose',
|
||||
|
@ -243,7 +250,10 @@ class Command(object):
|
|||
if options.verbose > 0:
|
||||
# The logger isn't setup yet
|
||||
print 'Running in environment %s' % options.venv
|
||||
restart_in_venv(options.venv, complete_args)
|
||||
site_packages=False
|
||||
if options.site_packages:
|
||||
site_packages=True
|
||||
restart_in_venv(options.venv, site_packages, complete_args)
|
||||
# restart_in_venv should actually never return, but for clarity...
|
||||
return
|
||||
## FIXME: not sure if this sure come before or after venv restart
|
||||
|
@ -951,7 +961,7 @@ def format_exc(exc_info=None):
|
|||
traceback.print_exception(*exc_info, **dict(file=out))
|
||||
return out.getvalue()
|
||||
|
||||
def restart_in_venv(venv, args):
|
||||
def restart_in_venv(venv, site_packages, args):
|
||||
"""
|
||||
Restart this script using the interpreter in the given virtual environment
|
||||
"""
|
||||
|
@ -968,8 +978,7 @@ def restart_in_venv(venv, args):
|
|||
print 'Creating new virtualenv environment in %s' % venv
|
||||
virtualenv.logger = logger
|
||||
logger.indent += 2
|
||||
## FIXME: always have no_site_packages?
|
||||
virtualenv.create_environment(venv, site_packages=False)
|
||||
virtualenv.create_environment(venv, site_packages=site_packages)
|
||||
if sys.platform == 'win32':
|
||||
python = os.path.join(venv, 'Scripts', 'python.exe')
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue