Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip install was skipping packages that were installed elsewhere #5255

Merged
merged 5 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: '^(pipenv/patched/|pipenv/vendor/|tests/)'
exclude: '^(pipenv/patched/|pipenv/vendor/|tests/|pipenv/pipenv.1)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
1 change: 1 addition & 0 deletions news/5254.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pip_install`` method was using a different way of finding the python executable than other ``pipenv`` commands, which caused an issue with skipping package installation if it was already installed in site-packages.
20 changes: 9 additions & 11 deletions pipenv/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import json as simplejson
import logging
import os
Expand All @@ -10,6 +8,7 @@
import warnings
from pathlib import Path
from posixpath import expandvars
from typing import Dict, List, Optional, Union

import dotenv
import pipfile
Expand All @@ -24,6 +23,7 @@
install_req_from_parsed_requirement,
)
from pipenv.patched.pip._internal.req.req_file import parse_requirements
from pipenv.project import Project
from pipenv.utils.constants import MYPY_RUNNING
from pipenv.utils.dependencies import (
convert_deps_to_pip,
Expand All @@ -50,12 +50,9 @@
)
from pipenv.utils.spinner import create_spinner
from pipenv.vendor import click
from pipenv.vendor.requirementslib.models.requirements import Requirement

if MYPY_RUNNING:
from typing import Dict, List, Optional, Union

from pipenv.project import Project
from pipenv.vendor.requirementslib.models.requirements import Requirement

TSourceDict = Dict[str, Union[str, bool]]

Expand Down Expand Up @@ -1211,7 +1208,7 @@ def do_purge(project, bare=False, downloads=False, allow_global=False):
click.echo(fix_utf8(f"Found {len(to_remove)} installed package(s), purging..."))

command = [
project_python(project),
project_python(project, system=allow_global),
_get_runnable_pip(),
"uninstall",
"-y",
Expand Down Expand Up @@ -1529,9 +1526,10 @@ def pip_install(
)

pip_command = [
project._which("python", allow_global=allow_global),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how many other issues this method causes... and there is also project.which... what a horror ...

project_python(project, system=allow_global),
_get_runnable_pip(),
"install",
"--ignore-installed",
]
pip_args = get_pip_args(
project,
Expand Down Expand Up @@ -2363,7 +2361,7 @@ def do_uninstall(
if package_name in packages_to_remove:
with project.environment.activated():
cmd = [
project_python(project),
project_python(project, system=system),
_get_runnable_pip(),
"uninstall",
package_name,
Expand Down Expand Up @@ -2669,7 +2667,7 @@ def do_check(
safety_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "patched", "safety"
)
_cmd = [project_python(project)]
_cmd = [project_python(project, system=system)]
# Run the PEP 508 checker in the virtualenv.
cmd = _cmd + [Path(pep508checker_path).as_posix()]
c = run_command(cmd, is_verbose=project.s.is_verbose())
Expand Down Expand Up @@ -3017,7 +3015,7 @@ def do_clean(
)
# Uninstall the package.
cmd = [
project_python(project),
project_python(project, system=system),
_get_runnable_pip(),
"uninstall",
apparent_bad_package,
Expand Down