Skip to content

Commit

Permalink
Corrected mistakes with refactor that were affecting the uninstall te…
Browse files Browse the repository at this point in the history
…sts -- not everything was being installed or locked as needed
  • Loading branch information
matteius committed Oct 25, 2024
1 parent 315acd0 commit 1d2b20d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def uninstall(ctx, state, all_dev=False, all=False, **kwargs):
all=all,
pre=pre,
pypi_mirror=state.pypi_mirror,
categories=state.installstate.categories,
pipfile_categories=state.installstate.categories,
ctx=ctx,
)
if retcode:
Expand Down
18 changes: 12 additions & 6 deletions pipenv/routines/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ def handle_lockfile(
categories,
):
"""Handle the lockfile, updating if necessary. Returns True if package updates were applied."""
if (project.lockfile_exists and not ignore_pipfile) and not skip_lock:
if (
(project.lockfile_exists and not ignore_pipfile)
and not skip_lock
and not packages
):
old_hash = project.get_lockfile_hash()
new_hash = project.calculate_pipfile_hash()
if new_hash != old_hash:
Expand Down Expand Up @@ -208,7 +212,7 @@ def handle_outdated_lockfile(
pre=pre,
write=True,
pypi_mirror=pypi_mirror,
categories=categories,
categories=None,
)


Expand Down Expand Up @@ -285,6 +289,7 @@ def do_install(
deploy=deploy,
pypi_mirror=pypi_mirror,
skip_lock=skip_lock,
categories=pipfile_categories,
)

do_install_validations(
Expand All @@ -301,7 +306,7 @@ def do_install(
skip_lock=skip_lock,
)
if not deploy:
new_packages, packages_installed = handle_new_packages(
new_packages, _ = handle_new_packages(
project,
packages,
editable_packages,
Expand All @@ -314,10 +319,10 @@ def do_install(
perform_upgrades=not skip_lock,
index=index,
)
if not dev and len(pipfile_categories) == 1 and packages_installed:
sys.exit(0)

try:
if dev: # Install both develop and default package categories from Pipfile.
pipfile_categories = ["default", "develop"]
do_install_dependencies(
project,
dev=dev,
Expand Down Expand Up @@ -678,6 +683,7 @@ def do_init(
pre=False,
pypi_mirror=None,
skip_lock=False,
categories=None,
):
"""Initialize the project, ensuring that the Pipfile and Pipfile.lock are in place.
Returns True if packages were updated + installed.
Expand All @@ -695,7 +701,7 @@ def do_init(
deploy=deploy,
pre=pre,
pypi_mirror=pypi_mirror,
categories=None,
categories=categories,
)

if not allow_global and not deploy and "PIPENV_ACTIVE" not in os.environ:
Expand Down
4 changes: 2 additions & 2 deletions pipenv/routines/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def upgrade(

if not package_args:
err.print("Nothing to upgrade!")
sys.exit(0)
return
else:
err.print(
f"[bold][green]Upgrading[/bold][/green] {', '.join(package_args)} in [{category}] dependencies."
Expand All @@ -314,7 +314,7 @@ def upgrade(
)
if not upgrade_lock_data:
err.print("Nothing to upgrade!")
sys.exit(0)
return

complete_packages = project.parsed_pipfile.get(pipfile_category, {})

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_uninstall_all_dev(pipenv_instance_private_pypi):
"""
f.write(contents)

c = p.pipenv("install --dev")
c = p.pipenv("install -v --dev")
assert c.returncode == 0

assert "tablib" in p.pipfile["packages"]
Expand All @@ -134,7 +134,7 @@ def test_uninstall_all_dev(pipenv_instance_private_pypi):
assert "six" in p.lockfile["develop"]
assert c.returncode == 0

c = p.pipenv("uninstall --all-dev")
c = p.pipenv("uninstall -v --all-dev")
assert c.returncode == 0
assert p.pipfile["dev-packages"] == {}
assert "jinja2" not in p.lockfile["develop"]
Expand Down

0 comments on commit 1d2b20d

Please sign in to comment.