mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
+58
-55
@@ -632,77 +632,80 @@ def do_lock(verbose=False):
|
||||
# Create the lockfile.
|
||||
lockfile = project._lockfile
|
||||
|
||||
# Cleanup lockfile.
|
||||
for section in ('default', 'develop'):
|
||||
for k, v in lockfile[section].copy().items():
|
||||
if not hasattr(v, 'keys'):
|
||||
del lockfile[section][k]
|
||||
with spinner():
|
||||
# Cleanup lockfile.
|
||||
for section in ('default', 'develop'):
|
||||
for k, v in lockfile[section].copy().items():
|
||||
if not hasattr(v, 'keys'):
|
||||
del lockfile[section][k]
|
||||
|
||||
# Resolve dev-package dependencies, with pip-tools.
|
||||
deps = convert_deps_to_pip(project.dev_packages, r=False)
|
||||
results = resolve_deps(deps, sources=project.sources, verbose=verbose)
|
||||
# Resolve dev-package dependencies, with pip-tools.
|
||||
deps = convert_deps_to_pip(project.dev_packages, r=False)
|
||||
results = resolve_deps(deps, sources=project.sources, verbose=verbose)
|
||||
|
||||
# Add develop dependencies to lockfile.
|
||||
for dep in results:
|
||||
lockfile['develop'].update({dep['name']: {'version': '=={0}'.format(dep['version'])}})
|
||||
lockfile['develop'][dep['name']]['hashes'] = dep['hashes']
|
||||
# Add develop dependencies to lockfile.
|
||||
for dep in results:
|
||||
lockfile['develop'].update({dep['name']: {'version': '=={0}'.format(dep['version'])}})
|
||||
lockfile['develop'][dep['name']]['hashes'] = dep['hashes']
|
||||
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
vcs_deps = convert_deps_to_pip(project.vcs_dev_packages, r=False)
|
||||
pip_freeze = delegator.run('{0} freeze'.format(which_pip())).out
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
vcs_deps = convert_deps_to_pip(project.vcs_dev_packages, r=False)
|
||||
pip_freeze = delegator.run('{0} freeze'.format(which_pip())).out
|
||||
|
||||
for dep in vcs_deps:
|
||||
for line in pip_freeze.strip().split('\n'):
|
||||
try:
|
||||
installed = convert_deps_from_pip(line)
|
||||
name = list(installed.keys())[0]
|
||||
for dep in vcs_deps:
|
||||
for line in pip_freeze.strip().split('\n'):
|
||||
try:
|
||||
installed = convert_deps_from_pip(line)
|
||||
name = list(installed.keys())[0]
|
||||
|
||||
if is_vcs(installed[name]):
|
||||
lockfile['develop'].update(installed)
|
||||
except IndexError:
|
||||
pass
|
||||
if is_vcs(installed[name]):
|
||||
lockfile['develop'].update(installed)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
# Alert the user of progress.
|
||||
click.echo(crayons.yellow(u'Locking {0} dependencies…'.format(crayons.red('[packages]'))), err=True)
|
||||
|
||||
# Resolve package dependencies, with pip-tools.
|
||||
deps = convert_deps_to_pip(project.packages, r=False)
|
||||
results = resolve_deps(deps, sources=project.sources)
|
||||
with spinner():
|
||||
# Resolve package dependencies, with pip-tools.
|
||||
deps = convert_deps_to_pip(project.packages, r=False)
|
||||
results = resolve_deps(deps, sources=project.sources)
|
||||
|
||||
# Add default dependencies to lockfile.
|
||||
for dep in results:
|
||||
lockfile['default'].update({dep['name']: {'version': '=={0}'.format(dep['version'])}})
|
||||
lockfile['default'][dep['name']]['hashes'] = dep['hashes']
|
||||
# Add default dependencies to lockfile.
|
||||
for dep in results:
|
||||
lockfile['default'].update({dep['name']: {'version': '=={0}'.format(dep['version'])}})
|
||||
lockfile['default'][dep['name']]['hashes'] = dep['hashes']
|
||||
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
vcs_deps = convert_deps_to_pip(project.vcs_packages, r=False)
|
||||
pip_freeze = delegator.run('{0} freeze'.format(which_pip())).out
|
||||
# Add refs for VCS installs.
|
||||
# TODO: be smarter about this.
|
||||
vcs_deps = convert_deps_to_pip(project.vcs_packages, r=False)
|
||||
pip_freeze = delegator.run('{0} freeze'.format(which_pip())).out
|
||||
|
||||
for dep in vcs_deps:
|
||||
for line in pip_freeze.strip().split('\n'):
|
||||
try:
|
||||
installed = convert_deps_from_pip(line)
|
||||
name = list(installed.keys())[0]
|
||||
for dep in vcs_deps:
|
||||
for line in pip_freeze.strip().split('\n'):
|
||||
try:
|
||||
installed = convert_deps_from_pip(line)
|
||||
name = list(installed.keys())[0]
|
||||
|
||||
if is_vcs(installed[name]):
|
||||
lockfile['default'].update(installed)
|
||||
except IndexError:
|
||||
pass
|
||||
if is_vcs(installed[name]):
|
||||
lockfile['default'].update(installed)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
# Run the PEP 508 checker in the virtualenv, add it to the lockfile.
|
||||
cmd = '"{0}" {1}'.format(which('python'), shellquote(pep508checker.__file__.rstrip('cdo')))
|
||||
c = delegator.run(cmd)
|
||||
lockfile['_meta']['host-environment-markers'] = json.loads(c.out)
|
||||
with spinner():
|
||||
# Run the PEP 508 checker in the virtualenv, add it to the lockfile.
|
||||
cmd = '"{0}" {1}'.format(which('python'), shellquote(pep508checker.__file__.rstrip('cdo')))
|
||||
c = delegator.run(cmd)
|
||||
lockfile['_meta']['host-environment-markers'] = json.loads(c.out)
|
||||
|
||||
# Write out the lockfile.
|
||||
with open(project.lockfile_location, 'w') as f:
|
||||
json.dump(lockfile, f, indent=4, separators=(',', ': '), sort_keys=True)
|
||||
# Write newline at end of document. GH Issue #319.
|
||||
f.write('\n')
|
||||
# Write out the lockfile.
|
||||
with open(project.lockfile_location, 'w') as f:
|
||||
json.dump(lockfile, f, indent=4, separators=(',', ': '), sort_keys=True)
|
||||
# Write newline at end of document. GH Issue #319.
|
||||
f.write('\n')
|
||||
|
||||
click.echo('{0} Pipfile.lock{1}'.format(crayons.yellow('Updated'), crayons.yellow('!')), err=True)
|
||||
click.echo('{0} Pipfile.lock{1}'.format(crayons.yellow('Updated'), crayons.yellow('!')), err=True)
|
||||
|
||||
|
||||
def activate_virtualenv(source=True):
|
||||
|
||||
Reference in New Issue
Block a user