mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
@@ -61,12 +61,6 @@ def setup_verbose(ctx, param, value):
|
||||
invoke_without_command=True,
|
||||
context_settings=CONTEXT_SETTINGS,
|
||||
)
|
||||
@click.option(
|
||||
'--update',
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Update Pipenv & pip to latest.",
|
||||
)
|
||||
@click.option(
|
||||
'--where',
|
||||
is_flag=True,
|
||||
@@ -133,7 +127,6 @@ def cli(
|
||||
three=False,
|
||||
python=False,
|
||||
help=False,
|
||||
update=False,
|
||||
py=False,
|
||||
site_packages=False,
|
||||
envs=False,
|
||||
@@ -156,15 +149,6 @@ def cli(
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
from .import core
|
||||
|
||||
if not update:
|
||||
pass
|
||||
else:
|
||||
# Update pip to latest version.
|
||||
core.ensure_latest_pip()
|
||||
# Upgrade self to latest version.
|
||||
core.ensure_latest_self()
|
||||
sys.exit()
|
||||
if man:
|
||||
if core.system_which('man'):
|
||||
path = os.sep.join([os.path.dirname(__file__), 'pipenv.1'])
|
||||
|
||||
@@ -169,50 +169,6 @@ def add_to_path(p):
|
||||
)
|
||||
|
||||
|
||||
def ensure_latest_self(user=False):
|
||||
"""Updates Pipenv to latest version, cleverly."""
|
||||
touch_update_stamp()
|
||||
try:
|
||||
r = requests.get('https://pypi.python.org/pypi/pipenv/json', timeout=2)
|
||||
except requests.RequestException as e:
|
||||
click.echo(crayons.red(e))
|
||||
sys.exit(1)
|
||||
latest = max(map(semver.parse_version_info, r.json()['releases'].keys()))
|
||||
current = semver.parse_version_info(__version__)
|
||||
if current < latest:
|
||||
import site
|
||||
|
||||
click.echo(
|
||||
'{0}: {1} is now available. Automatically upgrading!'.format(
|
||||
crayons.green('Courtesy Notice'),
|
||||
crayons.yellow(
|
||||
'Pipenv {v.major}.{v.minor}.{v.patch}'.format(v=latest)
|
||||
),
|
||||
),
|
||||
err=True,
|
||||
)
|
||||
# Resolve user site, enable user mode automatically.
|
||||
if site.ENABLE_USER_SITE and site.USER_SITE in sys.modules[
|
||||
'pipenv'
|
||||
].__file__:
|
||||
args = ['install', '--user', '--upgrade', 'pipenv', '--no-cache']
|
||||
else:
|
||||
args = ['install', '--upgrade', 'pipenv', '--no-cache']
|
||||
os.environ['PIP_PYTHON_VERSION'] = str(
|
||||
'.'.join(map(str, sys.version_info[:3]))
|
||||
)
|
||||
os.environ['PIP_PYTHON_PATH'] = str(sys.executable)
|
||||
sys.modules['pip'].main(args)
|
||||
click.echo(
|
||||
'{0} to {1}!'.format(
|
||||
crayons.green('Pipenv updated'),
|
||||
crayons.yellow(
|
||||
'{v.major}.{v.minor}.{v.patch}'.format(v=latest)
|
||||
),
|
||||
)
|
||||
)
|
||||
else:
|
||||
click.echo(crayons.green('All good!'))
|
||||
|
||||
|
||||
def cleanup_virtualenv(bare=True):
|
||||
@@ -226,33 +182,6 @@ def cleanup_virtualenv(bare=True):
|
||||
click.echo(e)
|
||||
|
||||
|
||||
def ensure_latest_pip():
|
||||
"""Updates pip to the latest version."""
|
||||
# Ensure that pip is installed.
|
||||
try:
|
||||
c = delegator.run(
|
||||
'{0} install pip'.format(escape_grouped_arguments(which_pip()))
|
||||
)
|
||||
# Check if version is out of date.
|
||||
if 'however' in c.err:
|
||||
# If version is out of date, update.
|
||||
click.echo(
|
||||
crayons.normal(
|
||||
u'Pip is out of date… updating to latest.', bold=True
|
||||
)
|
||||
)
|
||||
windows = '-m' if os.name == 'nt' else ''
|
||||
c = delegator.run(
|
||||
'{0} install {1} pip --upgrade'.format(
|
||||
escape_grouped_arguments(which_pip()), windows
|
||||
),
|
||||
block=False,
|
||||
)
|
||||
click.echo(crayons.blue(c.out))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
def import_requirements(r=None, dev=False):
|
||||
import pip9
|
||||
from pip9.req.req_file import parse_requirements
|
||||
|
||||
Reference in New Issue
Block a user