Skip to content

Commit

Permalink
Fix issue with skip-lock (#5653)
Browse files Browse the repository at this point in the history
* Fix issue with skip-lock
  • Loading branch information
matteius authored Apr 18, 2023
1 parent 4300e01 commit d7d4f6a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
rev: v0.0.259
hooks:
- id: ruff
# args: [--fix, --exit-non-zero-on-fix]
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black
rev: 23.1.0
Expand Down
1 change: 1 addition & 0 deletions news/5653.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression with ``--skip-lock`` option with ``install`` command.
23 changes: 14 additions & 9 deletions pipenv/routines/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pipenv.utils.requirements import import_requirements
from pipenv.utils.virtualenv import cleanup_virtualenv, do_create_virtualenv
from pipenv.vendor import click, vistir
from pipenv.vendor.requirementslib.models.requirements import Requirement

console = rich.console.Console()
err = rich.console.Console(stderr=True)
Expand Down Expand Up @@ -375,7 +376,7 @@ def do_install(
st.console.print(
environments.PIPENV_SPINNER_OK_TEXT.format("Installation Succeeded")
)
# Update project settings with pre preference.
# Update project settings with pre-release preference.
if pre:
project.update_settings({"allow_prereleases": pre})
do_init(
Expand Down Expand Up @@ -473,15 +474,14 @@ def do_install_dependencies(
else:
categories = ["packages"]

lockfile = None
pipfile = None
for category in categories:
# Load the lockfile if it exists, or if dev_only is being used.
if skip_lock or not project.lockfile_exists:
if skip_lock:
if not bare:
click.secho("Installing dependencies from Pipfile...", bold=True)
# skip_lock should completely bypass the lockfile (broken in 4dac1676)
lockfile = project.get_or_create_lockfile(
categories=categories, from_pipfile=True
)
pipfile = project.get_pipfile_section(category)
else:
lockfile = project.get_or_create_lockfile(categories=categories)
if not bare:
Expand All @@ -492,9 +492,14 @@ def do_install_dependencies(
bold=True,
)
dev = dev or dev_only
deps_list = list(
lockfile.get_requirements(dev=dev, only=dev_only, categories=[category])
)
if lockfile:
deps_list = list(
lockfile.get_requirements(dev=dev, only=dev_only, categories=[category])
)
else:
deps_list = []
for req_name, specifier in pipfile.items():
deps_list.append(Requirement.from_pipfile(req_name, specifier))
failed_deps_queue = queue.Queue()
if skip_lock:
ignore_hashes = True
Expand Down

0 comments on commit d7d4f6a

Please sign in to comment.