mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
+95
-107
@@ -103,18 +103,6 @@ if PIPENV_NOSPIN:
|
||||
def spinner():
|
||||
yield
|
||||
|
||||
|
||||
def puts(s, err=False):
|
||||
"""Better than click.echo, apparently."""
|
||||
|
||||
if sys.version_info[1] < 3:
|
||||
|
||||
if isinstance(s, unicode):
|
||||
s = s.encode('utf-8')
|
||||
|
||||
return click.echo(s, err=err)
|
||||
|
||||
|
||||
# Disable warnings for Python 2.6.
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
@@ -130,7 +118,7 @@ def check_for_updates():
|
||||
current = semver.parse_version_info(__version__)
|
||||
|
||||
if latest > current:
|
||||
puts('{0}: {1} is now available. You get bonus points for upgrading ($ {})!'.format(
|
||||
click.echo('{0}: {1} is now available. You get bonus points for upgrading ($ {})!'.format(
|
||||
crayons.green('Courtesy Notice'),
|
||||
crayons.yellow('Pipenv {v.major}.{v.minor}.{v.patch}'.format(v=latest)),
|
||||
crayons.red('pipenv --update')
|
||||
@@ -153,7 +141,7 @@ def ensure_latest_self(user=False):
|
||||
|
||||
import site
|
||||
|
||||
puts('{0}: {1} is now available. Automatically upgrading!'.format(
|
||||
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)
|
||||
@@ -166,19 +154,19 @@ def ensure_latest_self(user=False):
|
||||
|
||||
sys.modules['pip'].main(args)
|
||||
|
||||
puts('{0} to {1}!'.format(
|
||||
click.echo('{0} to {1}!'.format(
|
||||
crayons.green('Pipenv updated'),
|
||||
crayons.yellow('{v.major}.{v.minor}.{v.patch}'.format(v=latest))
|
||||
))
|
||||
else:
|
||||
puts(crayons.green('All good!'))
|
||||
click.echo(crayons.green('All good!'))
|
||||
|
||||
|
||||
def cleanup_virtualenv(bare=True):
|
||||
"""Removes the virtualenv directory from the system."""
|
||||
|
||||
if not bare:
|
||||
puts(crayons.red('Environment creation aborted.'))
|
||||
click.echo(crayons.red('Environment creation aborted.'))
|
||||
|
||||
try:
|
||||
# Delete the virtualenv.
|
||||
@@ -197,12 +185,12 @@ def ensure_latest_pip():
|
||||
# Check if version is out of date.
|
||||
if 'however' in c.err:
|
||||
# If version is out of date, update.
|
||||
puts(crayons.white(u'Pip is out of date… updating to latest.', bold=True))
|
||||
click.echo(crayons.white(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(which_pip()), windows, block=False)
|
||||
puts(crayons.blue(c.out))
|
||||
click.echo(crayons.blue(c.out))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
@@ -240,7 +228,7 @@ def ensure_environment():
|
||||
# Skip this on Windows...
|
||||
if os.name != 'nt':
|
||||
if 'LANG' not in os.environ:
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}: the environment variable {1} is not set!'
|
||||
'\nWe recommend setting this in {2} (or equivalent) for '
|
||||
'proper expected behavior.'.format(
|
||||
@@ -261,7 +249,7 @@ def ensure_pipfile(validate=True):
|
||||
|
||||
# If there's a requirements file, but no Pipfile...
|
||||
if project.requirements_exists:
|
||||
puts(crayons.white(u'Requirements.txt found, instead of Pipfile! Converting…', bold=True))
|
||||
click.echo(crayons.white(u'Requirements.txt found, instead of Pipfile! Converting…', bold=True))
|
||||
|
||||
# Create a Pipfile...
|
||||
python = which('python') if not USING_DEFAULT_PYTHON else False
|
||||
@@ -283,7 +271,7 @@ def ensure_pipfile(validate=True):
|
||||
)
|
||||
|
||||
else:
|
||||
puts(crayons.white(u'Creating a Pipfile for this project…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Creating a Pipfile for this project…', bold=True), err=True)
|
||||
|
||||
# Create the pipfile if it doesn't exist.
|
||||
python = which('python') if not USING_DEFAULT_PYTHON else False
|
||||
@@ -297,7 +285,7 @@ def ensure_pipfile(validate=True):
|
||||
|
||||
# Write changes out to disk.
|
||||
if changed:
|
||||
puts(crayons.white(u'Fixing package names in Pipfile…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Fixing package names in Pipfile…', bold=True), err=True)
|
||||
project.write_toml(p)
|
||||
|
||||
|
||||
@@ -328,7 +316,7 @@ def find_a_system_python(python):
|
||||
def ensure_python(three=None, python=None):
|
||||
|
||||
def abort():
|
||||
puts(
|
||||
click.echo(
|
||||
'You can specify specific versions of Python with:\n {0}'.format(
|
||||
crayons.red('$ pipenv --python {0}'.format(os.sep.join(('path', 'to', 'python'))))
|
||||
), err=True
|
||||
@@ -352,7 +340,7 @@ def ensure_python(three=None, python=None):
|
||||
|
||||
if not path_to_python and python is not None:
|
||||
# We need to install Python.
|
||||
puts(
|
||||
click.echo(
|
||||
u'{0}: Python {1} {2}'.format(
|
||||
crayons.red('Warning', bold=True),
|
||||
crayons.blue(python),
|
||||
@@ -425,7 +413,7 @@ def ensure_python(three=None, python=None):
|
||||
c.block()
|
||||
|
||||
# Print the results, in a beautiful blue...
|
||||
puts(crayons.blue(c.out), err=True)
|
||||
click.echo(crayons.blue(c.out), err=True)
|
||||
|
||||
click.echo(
|
||||
crayons.white(u'Making Python installation global…', bold=True)
|
||||
@@ -464,8 +452,8 @@ def ensure_virtualenv(three=None, python=None):
|
||||
|
||||
# If --three, --two, or --python were passed...
|
||||
elif (python) or (three is not None):
|
||||
puts(crayons.red('Virtualenv already exists!'), err=True)
|
||||
puts(crayons.white(u'Removing existing virtualenv…', bold=True), err=True)
|
||||
click.echo(crayons.red('Virtualenv already exists!'), err=True)
|
||||
click.echo(crayons.white(u'Removing existing virtualenv…', bold=True), err=True)
|
||||
|
||||
USING_DEFAULT_PYTHON = False
|
||||
|
||||
@@ -493,7 +481,7 @@ def ensure_project(three=None, python=None, validate=True, system=False, warn=Tr
|
||||
path_to_python = which('python')
|
||||
|
||||
if project.required_python_version not in (python_version(path_to_python) or ''):
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}: Your Pipfile requires {1} {2}, '
|
||||
'but you are using {3} ({4}).'.format(
|
||||
crayons.red('Warning', bold=True),
|
||||
@@ -504,9 +492,9 @@ def ensure_project(three=None, python=None, validate=True, system=False, warn=Tr
|
||||
), err=True
|
||||
)
|
||||
# if not project.lockfile_exists:
|
||||
# puts('Pipfile.lock does not exist. Aborting.')
|
||||
# click.echo('Pipfile.lock does not exist. Aborting.')
|
||||
# sys.exit(1)
|
||||
puts(
|
||||
click.echo(
|
||||
' {0} will surely fail.'
|
||||
''.format(crayons.red('$ pipenv check')),
|
||||
err=True
|
||||
@@ -579,24 +567,24 @@ def do_where(virtualenv=False, bare=True):
|
||||
location = shorten_path(location)
|
||||
|
||||
if not location:
|
||||
puts(
|
||||
click.echo(
|
||||
'No Pipfile present at project home. Consider running '
|
||||
'{0} first to automatically generate a Pipfile for you.'
|
||||
''.format(crayons.green('`pipenv install`')), err=True)
|
||||
elif not bare:
|
||||
puts(
|
||||
click.echo(
|
||||
'Pipfile found at {0}.\n Considering this to be the project home.'
|
||||
''.format(crayons.green(location)), err=True)
|
||||
else:
|
||||
puts(location)
|
||||
click.echo(location)
|
||||
|
||||
else:
|
||||
location = project.virtualenv_location
|
||||
|
||||
if not bare:
|
||||
puts('Virtualenv location: {0}'.format(crayons.green(location)), err=True)
|
||||
click.echo('Virtualenv location: {0}'.format(crayons.green(location)), err=True)
|
||||
else:
|
||||
puts(location)
|
||||
click.echo(location)
|
||||
|
||||
|
||||
def do_install_dependencies(
|
||||
@@ -611,11 +599,11 @@ def do_install_dependencies(
|
||||
# Load the lockfile if it exists, or if only is being used (e.g. lock is being used).
|
||||
if skip_lock or only or not project.lockfile_exists:
|
||||
if not bare:
|
||||
puts(crayons.white(u'Installing dependencies from Pipfile…', bold=True))
|
||||
click.echo(crayons.white(u'Installing dependencies from Pipfile…', bold=True))
|
||||
lockfile = split_vcs(project._lockfile)
|
||||
else:
|
||||
if not bare:
|
||||
puts(crayons.white(u'Installing dependencies from Pipfile.lock…', bold=True))
|
||||
click.echo(crayons.white(u'Installing dependencies from Pipfile.lock…', bold=True))
|
||||
with open(project.lockfile_location) as f:
|
||||
lockfile = split_vcs(json.load(f))
|
||||
|
||||
@@ -649,7 +637,7 @@ def do_install_dependencies(
|
||||
|
||||
# --requirements was passed.
|
||||
if requirements:
|
||||
puts('\n'.join(d[0] for d in deps_list))
|
||||
click.echo('\n'.join(d[0] for d in deps_list))
|
||||
sys.exit(0)
|
||||
|
||||
# pip install:
|
||||
@@ -671,7 +659,7 @@ def do_install_dependencies(
|
||||
failed_deps_list.append((dep, ignore_hash))
|
||||
|
||||
# Alert the user.
|
||||
puts(
|
||||
click.echo(
|
||||
'{0} {1}! Will try again.'.format(
|
||||
crayons.red('An error occured while installing'),
|
||||
crayons.green(dep.split('--hash')[0].strip())
|
||||
@@ -681,7 +669,7 @@ def do_install_dependencies(
|
||||
# Iterate over the hopefully-poorly-packaged dependencies...
|
||||
if failed_deps_list:
|
||||
|
||||
puts(crayons.white(u'Installing initially–failed dependencies…', bold=True))
|
||||
click.echo(crayons.white(u'Installing initially–failed dependencies…', bold=True))
|
||||
|
||||
for dep, ignore_hash in progress.bar(failed_deps_list, label=INSTALL_LABEL2):
|
||||
# Install the module.
|
||||
@@ -697,13 +685,13 @@ def do_install_dependencies(
|
||||
if c.return_code != 0:
|
||||
|
||||
# We echo both c.out and c.err because pip returns error details on out.
|
||||
puts(crayons.blue(format_pip_output(c.out)))
|
||||
puts(crayons.blue(format_pip_error(c.err)))
|
||||
click.echo(crayons.blue(format_pip_output(c.out)))
|
||||
click.echo(crayons.blue(format_pip_error(c.err)))
|
||||
|
||||
# Return the subprocess' return code.
|
||||
sys.exit(c.return_code)
|
||||
else:
|
||||
puts('{0} {1}{2}'.format(
|
||||
click.echo('{0} {1}{2}'.format(
|
||||
crayons.green('Success installing'),
|
||||
crayons.green(dep.split('--hash')[0].strip()),
|
||||
crayons.green('!')
|
||||
@@ -717,7 +705,7 @@ def convert_three_to_python(three, python):
|
||||
if not python:
|
||||
if three is False:
|
||||
if os.name == 'nt':
|
||||
puts(
|
||||
click.echo(
|
||||
'{0} If you are running on Windows, you should use '
|
||||
'the {1} option, instead.'
|
||||
''.format(
|
||||
@@ -730,7 +718,7 @@ def convert_three_to_python(three, python):
|
||||
|
||||
elif three is True:
|
||||
if os.name == 'nt':
|
||||
puts(
|
||||
click.echo(
|
||||
'{0} If you are running on Windows, you should use '
|
||||
'the {1} option, instead.'
|
||||
''.format(
|
||||
@@ -747,7 +735,7 @@ def convert_three_to_python(three, python):
|
||||
def do_create_virtualenv(python=None):
|
||||
"""Creates a virtualenv."""
|
||||
|
||||
puts(crayons.white(u'Creating a virtualenv for this project…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Creating a virtualenv for this project…', bold=True), err=True)
|
||||
|
||||
# The user wants the virtualenv in the project.
|
||||
if PIPENV_VENV_IN_PROJECT:
|
||||
@@ -758,7 +746,7 @@ def do_create_virtualenv(python=None):
|
||||
|
||||
# Pass a Python version to virtualenv, if needed.
|
||||
if python:
|
||||
puts('{0} {1} {2}'.format(
|
||||
click.echo('{0} {1} {2}'.format(
|
||||
crayons.white('Using', bold=True),
|
||||
crayons.red(python, bold=True),
|
||||
crayons.white(u'to create virtualenv…', bold=True)
|
||||
@@ -773,7 +761,7 @@ def do_create_virtualenv(python=None):
|
||||
try:
|
||||
c = delegator.run(cmd, block=False, timeout=PIPENV_TIMEOUT)
|
||||
except OSError:
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}: it looks like {1} is not in your {2}. '
|
||||
'We cannot continue until this is resolved.'
|
||||
''.format(
|
||||
@@ -784,7 +772,7 @@ def do_create_virtualenv(python=None):
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
puts(crayons.blue(c.out), err=True)
|
||||
click.echo(crayons.blue(c.out), err=True)
|
||||
|
||||
# Say where the virtualenv is.
|
||||
do_where(virtualenv=True, bare=False)
|
||||
@@ -842,7 +830,7 @@ def do_lock(verbose=False):
|
||||
"""Executes the freeze functionality."""
|
||||
|
||||
# Alert the user of progress.
|
||||
puts(
|
||||
click.echo(
|
||||
u'{0} {1} {2}'.format(
|
||||
crayons.white('Locking'),
|
||||
crayons.red('[dev-packages]'),
|
||||
@@ -893,7 +881,7 @@ def do_lock(verbose=False):
|
||||
pass
|
||||
|
||||
# Alert the user of progress.
|
||||
puts(
|
||||
click.echo(
|
||||
u'{0} {1} {2}'.format(
|
||||
crayons.white('Locking'),
|
||||
crayons.red('[packages]'),
|
||||
@@ -945,7 +933,7 @@ def do_lock(verbose=False):
|
||||
# Write newline at end of document. GH Issue #319.
|
||||
f.write('\n')
|
||||
|
||||
puts('{0}'.format(crayons.white('Updated Pipfile.lock!', bold=True)), err=True)
|
||||
click.echo('{0}'.format(crayons.white('Updated Pipfile.lock!', bold=True)), err=True)
|
||||
|
||||
|
||||
def activate_virtualenv(source=True):
|
||||
@@ -977,11 +965,11 @@ def do_activate_virtualenv(bare=False):
|
||||
# Check for environment marker, and skip if it's set.
|
||||
if 'PIPENV_ACTIVE' not in os.environ:
|
||||
if not bare:
|
||||
puts('To activate this project\'s virtualenv, run the following:\n $ {0}'.format(
|
||||
click.echo('To activate this project\'s virtualenv, run the following:\n $ {0}'.format(
|
||||
crayons.red('pipenv shell'))
|
||||
)
|
||||
else:
|
||||
puts(activate_virtualenv())
|
||||
click.echo(activate_virtualenv())
|
||||
|
||||
|
||||
def do_purge(bare=False, downloads=False, allow_global=False):
|
||||
@@ -989,7 +977,7 @@ def do_purge(bare=False, downloads=False, allow_global=False):
|
||||
|
||||
if downloads:
|
||||
if not bare:
|
||||
puts(crayons.white(u'Clearing out downloads directory…', bold=True))
|
||||
click.echo(crayons.white(u'Clearing out downloads directory…', bold=True))
|
||||
shutil.rmtree(project.download_location)
|
||||
return
|
||||
|
||||
@@ -1003,13 +991,13 @@ def do_purge(bare=False, downloads=False, allow_global=False):
|
||||
del installed[i]
|
||||
|
||||
if not bare:
|
||||
puts(u'Found {0} installed package(s), purging…'.format(len(installed)))
|
||||
click.echo(u'Found {0} installed package(s), purging…'.format(len(installed)))
|
||||
command = '"{0}" uninstall {1} -y'.format(which_pip(allow_global=allow_global), ' '.join(installed))
|
||||
c = delegator.run(command)
|
||||
|
||||
if not bare:
|
||||
puts(crayons.blue(c.out))
|
||||
puts(crayons.green('Environment now purged and fresh!'))
|
||||
click.echo(crayons.blue(c.out))
|
||||
click.echo(crayons.green('Environment now purged and fresh!'))
|
||||
|
||||
|
||||
def do_init(
|
||||
@@ -1044,13 +1032,13 @@ def do_init(
|
||||
|
||||
# Check that the hash of the Lockfile matches the lockfile's hash.
|
||||
if not lockfile['_meta'].get('hash', {}).get('sha256') == p.hash:
|
||||
puts(crayons.red(u'Pipfile.lock out of date, updating…', bold=True), err=True)
|
||||
click.echo(crayons.red(u'Pipfile.lock out of date, updating…', bold=True), err=True)
|
||||
|
||||
do_lock()
|
||||
|
||||
# Write out the lockfile if it doesn't exist.
|
||||
if not project.lockfile_exists and not skip_lock:
|
||||
puts(crayons.white(u'Pipfile.lock not found, creating…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Pipfile.lock not found, creating…', bold=True), err=True)
|
||||
do_lock()
|
||||
|
||||
do_install_dependencies(dev=dev, requirements=requirements, allow_global=allow_global,
|
||||
@@ -1107,7 +1095,7 @@ def pip_install(
|
||||
)
|
||||
|
||||
if verbose:
|
||||
puts('$ {0}'.format(pip_command), err=True)
|
||||
click.echo('$ {0}'.format(pip_command), err=True)
|
||||
|
||||
c = delegator.run(pip_command)
|
||||
|
||||
@@ -1161,7 +1149,7 @@ def system_which(command):
|
||||
try:
|
||||
# Which Not found...
|
||||
if c.return_code == 127:
|
||||
puts(
|
||||
click.echo(
|
||||
'{}: the {} system utility is required for Pipenv to find Python installations properly.'
|
||||
'\n Please install it.'.format(
|
||||
crayons.red('Warning', bold=True),
|
||||
@@ -1252,9 +1240,9 @@ def kr_easter_egg(package_name):
|
||||
|
||||
# Windows built-in terminal lacks proper emoji taste.
|
||||
if PIPENV_HIDE_EMOJIS:
|
||||
puts(u'P.S. You have excellent taste!')
|
||||
click.echo(u'P.S. You have excellent taste!')
|
||||
else:
|
||||
puts(u'P.S. You have excellent taste! ✨ 🍰 ✨')
|
||||
click.echo(u'P.S. You have excellent taste! ✨ 🍰 ✨')
|
||||
|
||||
|
||||
@click.group(invoke_without_command=True)
|
||||
@@ -1276,7 +1264,7 @@ def cli(
|
||||
|
||||
if jumbotron:
|
||||
# Awesome sauce.
|
||||
puts(crayons.white(xyzzy, bold=True))
|
||||
click.echo(crayons.white(xyzzy, bold=True))
|
||||
|
||||
if not update:
|
||||
# Spun off in background thread, not unlike magic.
|
||||
@@ -1300,17 +1288,17 @@ def cli(
|
||||
elif venv:
|
||||
# There is no virtualenv yet.
|
||||
if not project.virtualenv_exists:
|
||||
puts(crayons.red('No virtualenv has been created for this project yet!'), err=True)
|
||||
click.echo(crayons.red('No virtualenv has been created for this project yet!'), err=True)
|
||||
sys.exit(1)
|
||||
else:
|
||||
puts(project.virtualenv_location)
|
||||
click.echo(project.virtualenv_location)
|
||||
sys.exit(0)
|
||||
|
||||
# --rm was passed...
|
||||
elif rm:
|
||||
if project.virtualenv_exists:
|
||||
loc = project.virtualenv_location
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(
|
||||
u'{0} ({1})…'.format(
|
||||
crayons.white('Removing virtualenv', bold=True),
|
||||
@@ -1324,7 +1312,7 @@ def cli(
|
||||
cleanup_virtualenv(bare=True)
|
||||
sys.exit(0)
|
||||
else:
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.red(
|
||||
'No virtualenv has been created for this project yet!',
|
||||
bold=True
|
||||
@@ -1339,7 +1327,7 @@ def cli(
|
||||
# Check this again before exiting for empty ``pipenv`` command.
|
||||
elif ctx.invoked_subcommand is None:
|
||||
# Display help to user, if no commands were passed.
|
||||
puts(format_help(ctx.get_help()))
|
||||
click.echo(format_help(ctx.get_help()))
|
||||
|
||||
|
||||
@click.command(help="Installs provided packages and adds them to Pipfile, or (if none is given), installs all packages.", context_settings=dict(
|
||||
@@ -1370,7 +1358,7 @@ def install(
|
||||
ensure_project(three=three, python=python, system=system, warn=True)
|
||||
|
||||
if requirements:
|
||||
puts(crayons.white(u'Requirements file provided! Importing into Pipfile…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Requirements file provided! Importing into Pipfile…', bold=True), err=True)
|
||||
import_requirements(r=requirements)
|
||||
|
||||
# Capture -e argument and assign it to following package_name.
|
||||
@@ -1383,35 +1371,35 @@ def install(
|
||||
|
||||
# Install all dependencies, if none was provided.
|
||||
if package_name is False:
|
||||
puts(crayons.white('No package provided, installing all dependencies.', bold=True), err=True)
|
||||
click.echo(crayons.white('No package provided, installing all dependencies.', bold=True), err=True)
|
||||
|
||||
do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, skip_lock=skip_lock, verbose=verbose)
|
||||
sys.exit(0)
|
||||
|
||||
for package_name in package_names:
|
||||
puts(crayons.white(u'Installing {0}…'.format(crayons.green(package_name, bold=True)), bold=True))
|
||||
click.echo(crayons.white(u'Installing {0}…'.format(crayons.green(package_name, bold=True)), bold=True))
|
||||
|
||||
# pip install:
|
||||
with spinner():
|
||||
c = pip_install(package_name, ignore_hashes=True, allow_global=system, no_deps=False, verbose=verbose)
|
||||
|
||||
puts(crayons.blue(format_pip_output(c.out)))
|
||||
click.echo(crayons.blue(format_pip_output(c.out)))
|
||||
|
||||
# Ensure that package was successfully installed.
|
||||
try:
|
||||
assert c.return_code == 0
|
||||
except AssertionError:
|
||||
puts('{0} An error occurred while installing {1}!'.format(crayons.red('Error: ', bold=True), crayons.green(package_name)))
|
||||
puts(crayons.blue(format_pip_error(c.err)))
|
||||
click.echo('{0} An error occurred while installing {1}!'.format(crayons.red('Error: ', bold=True), crayons.green(package_name)))
|
||||
click.echo(crayons.blue(format_pip_error(c.err)))
|
||||
sys.exit(1)
|
||||
|
||||
if dev:
|
||||
puts(crayons.white(u'Adding {0} to Pipfile\'s {1}…'.format(
|
||||
click.echo(crayons.white(u'Adding {0} to Pipfile\'s {1}…'.format(
|
||||
crayons.green(package_name),
|
||||
crayons.red('[dev-packages]')
|
||||
)))
|
||||
else:
|
||||
puts(crayons.white(u'Adding {0} to Pipfile\'s {1}…'.format(
|
||||
click.echo(crayons.white(u'Adding {0} to Pipfile\'s {1}…'.format(
|
||||
crayons.green(package_name),
|
||||
crayons.red('[packages]')
|
||||
)))
|
||||
@@ -1420,7 +1408,7 @@ def install(
|
||||
try:
|
||||
project.add_package_to_pipfile(package_name, dev)
|
||||
except ValueError as e:
|
||||
puts('{0} {1}'.format(crayons.red('ERROR (PACKAGE NOT INSTALLED):'), e))
|
||||
click.echo('{0} {1}'.format(crayons.red('ERROR (PACKAGE NOT INSTALLED):'), e))
|
||||
|
||||
# Ego boost.
|
||||
kr_easter_egg(package_name)
|
||||
@@ -1455,7 +1443,7 @@ def uninstall(
|
||||
|
||||
# Un-install all dependencies, if --all was provided.
|
||||
if all is True:
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(u'Un-installing all packages from virtualenv…', bold=True)
|
||||
)
|
||||
do_purge(allow_global=system)
|
||||
@@ -1464,14 +1452,14 @@ def uninstall(
|
||||
# Uninstall [dev-packages], if --dev was provided.
|
||||
if dev:
|
||||
if 'dev-packages' not in project.parsed_pipfile:
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white('No {0} to uninstall.'.format(
|
||||
crayons.red('[dev-packages]')), bold=True
|
||||
)
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(u'Un-installing {0}…'.format(
|
||||
crayons.red('[dev-packages]')), bold=True
|
||||
)
|
||||
@@ -1480,12 +1468,12 @@ def uninstall(
|
||||
package_names = package_names.keys()
|
||||
|
||||
if package_name is False and not dev:
|
||||
puts(crayons.red('No package provided!'))
|
||||
click.echo(crayons.red('No package provided!'))
|
||||
sys.exit(1)
|
||||
|
||||
for package_name in package_names:
|
||||
|
||||
puts(u'Un-installing {0}…'.format(
|
||||
click.echo(u'Un-installing {0}…'.format(
|
||||
crayons.green(package_name))
|
||||
)
|
||||
|
||||
@@ -1494,7 +1482,7 @@ def uninstall(
|
||||
package_name
|
||||
))
|
||||
|
||||
puts(crayons.blue(c.out))
|
||||
click.echo(crayons.blue(c.out))
|
||||
|
||||
if pipfile_remove:
|
||||
norm_name = pep423_name(package_name)
|
||||
@@ -1503,14 +1491,14 @@ def uninstall(
|
||||
in_packages = (norm_name in project._pipfile.get('packages', {}))
|
||||
|
||||
if not in_dev_packages and not in_packages:
|
||||
puts(
|
||||
click.echo(
|
||||
'No package {0} to remove from Pipfile.'.format(
|
||||
crayons.green(package_name)
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
u'Removing {0} from Pipfile…'.format(
|
||||
crayons.green(package_name)
|
||||
)
|
||||
@@ -1557,7 +1545,7 @@ def do_shell(three=None, python=False, compat=False, shell_args=None):
|
||||
try:
|
||||
shell = os.environ['SHELL']
|
||||
except KeyError:
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.red(
|
||||
'Please ensure that the {0} environment variable '
|
||||
'is set before activating shell.'.format(crayons.white('SHELL', bold=True))
|
||||
@@ -1565,7 +1553,7 @@ def do_shell(three=None, python=False, compat=False, shell_args=None):
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(
|
||||
'Spawning environment shell ({0}).'.format(
|
||||
crayons.red(shell)
|
||||
@@ -1641,7 +1629,7 @@ def shell(three=None, python=False, compat=False, shell_args=None, anyway=False)
|
||||
venv_name = os.environ.get('VIRTUAL_ENV', 'UNKNOWN_VIRTUAL_ENVIRONMENT')
|
||||
|
||||
if not anyway:
|
||||
puts('{0} {1} {2}\nNo action taken to avoid nested environments.'.format(
|
||||
click.echo('{0} {1} {2}\nNo action taken to avoid nested environments.'.format(
|
||||
crayons.white('Shell for'),
|
||||
crayons.green(venv_name, bold=True),
|
||||
crayons.white('already activated.', bold=True)
|
||||
@@ -1660,7 +1648,7 @@ def inline_activate_virtualenv():
|
||||
exec(code, dict(__file__=activate_this))
|
||||
# Catch all errors, just in case.
|
||||
except Exception:
|
||||
puts(
|
||||
click.echo(
|
||||
u'{0}: There was an unexpected error while activating your virtualenv. Continuing anyway…'
|
||||
''.format(crayons.red('Warning', bold=True)),
|
||||
err=True
|
||||
@@ -1700,7 +1688,7 @@ def run(command, args, three=None, python=False):
|
||||
else:
|
||||
command_path = system_which(command)
|
||||
if not command_path:
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}: the command {1} could not be found within {2}.'
|
||||
''.format(
|
||||
crayons.red('Error', bold=True),
|
||||
@@ -1723,7 +1711,7 @@ def check(three=None, python=False):
|
||||
# Ensure that virtualenv is available.
|
||||
ensure_project(three=three, python=python, validate=False, warn=False)
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(u'Checking PEP 508 requirements…', bold=True)
|
||||
)
|
||||
|
||||
@@ -1743,7 +1731,7 @@ def check(three=None, python=False):
|
||||
assert results[marker] == specifier
|
||||
except AssertionError:
|
||||
failed = True
|
||||
puts(
|
||||
click.echo(
|
||||
'Specifier {0} does not match {1} ({2}).'
|
||||
''.format(
|
||||
crayons.green(marker),
|
||||
@@ -1752,10 +1740,10 @@ def check(three=None, python=False):
|
||||
)
|
||||
)
|
||||
if failed:
|
||||
puts(crayons.red('Failed!'))
|
||||
click.echo(crayons.red('Failed!'))
|
||||
sys.exit(1)
|
||||
else:
|
||||
puts(crayons.green('Passed!'))
|
||||
click.echo(crayons.green('Passed!'))
|
||||
|
||||
|
||||
@click.command(help=u"Displays currently–installed dependency graph information.")
|
||||
@@ -1764,7 +1752,7 @@ def graph(bare=False):
|
||||
try:
|
||||
python_path = which('python')
|
||||
except AttributeError:
|
||||
puts(
|
||||
click.echo(
|
||||
u'{0}: {1}'.format(
|
||||
crayons.red('Warning', bold=True),
|
||||
u'Unable to display currently–installed dependency graph information here. '
|
||||
@@ -1791,13 +1779,13 @@ def graph(bare=False):
|
||||
|
||||
# Bold top-level packages.
|
||||
if not line.startswith(' '):
|
||||
puts(crayons.white(line, bold=True))
|
||||
click.echo(crayons.white(line, bold=True))
|
||||
|
||||
# Echo the rest.
|
||||
else:
|
||||
puts(crayons.white(line, bold=False))
|
||||
click.echo(crayons.white(line, bold=False))
|
||||
else:
|
||||
puts(c.out)
|
||||
click.echo(c.out)
|
||||
|
||||
# Return its return code.
|
||||
sys.exit(c.return_code)
|
||||
@@ -1822,7 +1810,7 @@ def update(dev=False, three=None, python=None, dry_run=False, bare=False, dont_u
|
||||
|
||||
# Dev packages
|
||||
if not bare:
|
||||
puts(crayons.white(u'Checking dependencies…', bold=True), err=True)
|
||||
click.echo(crayons.white(u'Checking dependencies…', bold=True), err=True)
|
||||
|
||||
packages = project.packages
|
||||
if dev:
|
||||
@@ -1849,12 +1837,12 @@ def update(dev=False, three=None, python=None, dry_run=False, bare=False, dont_u
|
||||
latest = installed_packages[name]
|
||||
if installed != latest:
|
||||
if not bare:
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}=={1} is available ({2} installed)!'
|
||||
''.format(crayons.white(name, bold=True), latest, installed)
|
||||
)
|
||||
else:
|
||||
puts(
|
||||
click.echo(
|
||||
'{0}=={1}'.format(name, latest)
|
||||
)
|
||||
updates = True
|
||||
@@ -1862,20 +1850,20 @@ def update(dev=False, three=None, python=None, dry_run=False, bare=False, dont_u
|
||||
pass
|
||||
|
||||
if not updates and not bare:
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.green('All good!')
|
||||
)
|
||||
|
||||
sys.exit(int(updates))
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.white(u'Updating all dependencies from Pipfile…', bold=True)
|
||||
)
|
||||
|
||||
do_purge()
|
||||
do_init(dev=dev, verbose=verbose)
|
||||
|
||||
puts(
|
||||
click.echo(
|
||||
crayons.green('All dependencies are now up-to-date!')
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user