Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
click.echo(crayons.blue(format_pip_error(c.err)), err=True)
if 'setup.py egg_info' in c.err:
click.echo(
"This is likely caused by a bug in {0}. "
"Report this to its maintainers.".format(
crayons.green(package_name),
),
err=True,
)
requirements_directory.cleanup()
sys.exit(1)
click.echo(
'{0} {1} {2} {3}{4}'.format(
crayons.normal('Adding', bold=True),
crayons.green(package_name, bold=True),
crayons.normal("to Pipfile's", bold=True),
crayons.red(
'[dev-packages]' if dev else '[packages]', bold=True
),
crayons.normal('...', bold=True),
)
)
# Add the package to the Pipfile.
try:
project.add_package_to_pipfile(package_name, dev)
except ValueError as e:
click.echo(
'{0} {1}'.format(
crayons.red('ERROR (PACKAGE NOT INSTALLED):'), e
)
)
)
results = json.loads(c.out)
# Load the pipfile.
p = pipfile.Pipfile.load(project.pipfile_location)
failed = False
# Assert each specified requirement.
for marker, specifier in p.data['_meta']['requires'].items():
if marker in results:
try:
assert results[marker] == specifier
except AssertionError:
failed = True
click.echo(
'Specifier {0} does not match {1} ({2}).'
''.format(
crayons.green(marker),
crayons.blue(specifier),
crayons.red(results[marker]),
),
err=True,
)
if failed:
click.echo(crayons.red('Failed!'), err=True)
sys.exit(1)
else:
click.echo(crayons.green('Passed!'))
click.echo(
crayons.normal(u'Checking installed package safety...', bold=True)
)
path = pep508checker.__file__.rstrip('cdo')
path = os.sep.join(__file__.split(os.sep)[:-1] + ['patched', 'safety.zip'])
if not system:
if unused:
deps_required = [k for k in project.packages.keys()]
deps_needed = import_from_code(unused)
for dep in deps_needed:
try:
deps_required.remove(dep)
except ValueError:
pass
if deps_required:
click.echo(
crayons.normal(
'The following dependencies appear unused, and may be safe for removal:'
)
)
for dep in deps_required:
click.echo(' - {0}'.format(crayons.green(dep)))
sys.exit(1)
else:
sys.exit(0)
click.echo(crayons.normal(u'Checking PEP 508 requirements...', bold=True))
if system:
python = system_which('python')
else:
python = which('python')
# Run the PEP 508 checker in the virtualenv.
c = delegator.run(
'"{0}" {1}'.format(
python,
escape_grouped_arguments(pep508checker.__file__.rstrip('cdo')),
)
)
results = json.loads(c.out)
# Install everything.
requirements_dir = TemporaryDirectory(
suffix='-requirements', prefix='pipenv-'
)
do_init(
dev=dev,
verbose=verbose,
concurrent=(not sequential),
requirements_dir=requirements_dir,
ignore_pipfile=True, # Don't check if Pipfile and lock match.
pypi_mirror=pypi_mirror,
deploy=deploy,
system=system,
)
requirements_dir.cleanup()
click.echo(crayons.green('All dependencies are now up-to-date!'))
)
help = help.replace(' check', str(crayons.red(' check', bold=True)))
help = help.replace(' clean', str(crayons.red(' clean', bold=True)))
help = help.replace(' graph', str(crayons.red(' graph', bold=True)))
help = help.replace(
' install', str(crayons.magenta(' install', bold=True))
)
help = help.replace(' lock', str(crayons.green(' lock', bold=True)))
help = help.replace(' open', str(crayons.red(' open', bold=True)))
help = help.replace(' run', str(crayons.yellow(' run', bold=True)))
help = help.replace(' shell', str(crayons.yellow(' shell', bold=True)))
help = help.replace(' sync', str(crayons.green(' sync', bold=True)))
help = help.replace(
' uninstall', str(crayons.magenta(' uninstall', bold=True))
)
help = help.replace(' update', str(crayons.green(' update', bold=True)))
additional_help = """
Usage Examples:
Create a new project using Python 3.6, specifically:
$ {1}
Install all dependencies for a project (including dev):
$ {2}
Create a lockfile containing pre-releases:
$ {6}
Show a graph of your installed dependencies:
$ {4}
Check your installed dependencies for security vulnerabilities:
$ {7}
def do_where(virtualenv=False, bare=True):
"""Executes the where functionality."""
if not virtualenv:
location = project.pipfile_location
# Shorten the virtual display of the path to the virtualenv.
if not bare:
location = shorten_path(location)
if not location:
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:
click.echo(
'Pipfile found at {0}.\n Considering this to be the project home.'
''.format(crayons.green(location)),
err=True,
)
pass
else:
click.echo(project.project_directory)
else:
location = project.virtualenv_location
if not bare:
click.echo(
'Virtualenv location: {0}'.format(crayons.green(location)),
python_version(path_to_python) or ""
):
click.echo(
"{0}: Your Pipfile requires {1} {2}, "
"but you are using {3} ({4}).".format(
crayons.red("Warning", bold=True),
crayons.normal("python_version", bold=True),
crayons.blue(project.required_python_version),
crayons.blue(python_version(path_to_python) or "unknown"),
crayons.green(shorten_path(path_to_python)),
),
err=True,
)
click.echo(
" {0} and rebuilding the virtual environment "
"may resolve the issue.".format(crayons.green("$ pipenv --rm")),
err=True,
)
if not deploy:
click.echo(
" {0} will surely fail."
"".format(crayons.red("$ pipenv check")),
err=True,
)
else:
raise exceptions.DeployException
# Ensure the Pipfile exists.
ensure_pipfile(
validate=validate, skip_requirements=skip_requirements, system=system
)
)
if warn:
# Warn users if they are using the wrong version of Python.
if project.required_python_version:
path_to_python = which("python") or which("py")
if path_to_python and project.required_python_version not in (
python_version(path_to_python) or ""
):
click.echo(
"{0}: Your Pipfile requires {1} {2}, "
"but you are using {3} ({4}).".format(
crayons.red("Warning", bold=True),
crayons.normal("python_version", bold=True),
crayons.blue(project.required_python_version),
crayons.blue(python_version(path_to_python) or "unknown"),
crayons.green(shorten_path(path_to_python)),
),
err=True,
)
click.echo(
" {0} and rebuilding the virtual environment "
"may resolve the issue.".format(crayons.green("$ pipenv --rm")),
err=True,
)
if not deploy:
click.echo(
" {0} will surely fail."
"".format(crayons.red("$ pipenv check")),
err=True,
)
else:
raise exceptions.DeployException