Skip to content

Commit

Permalink
Remove the sys path hacks (again) to fix edge cases with keyring (#5732)
Browse files Browse the repository at this point in the history
* Remove the sys path hacks (again) to see where things break.
* Add site packages to sync
  • Loading branch information
matteius authored Jun 12, 2023
1 parent d118cc7 commit 1cc03ea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions news/5719.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the ``sys.path`` modifications and as a result fixes keyring support.
16 changes: 1 addition & 15 deletions pipenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
# |~~\' |~~
# |__/||~~\|--|/~\\ /
# | ||__/|__| |\/
# |

import os
import sys
import warnings

from pipenv.__version__ import __version__ # noqa
from pipenv.cli import cli
from pipenv.patched.pip._vendor.urllib3.exceptions import DependencyWarning

warnings.filterwarnings("ignore", category=DependencyWarning)
warnings.filterwarnings("ignore", category=ResourceWarning)
warnings.filterwarnings("ignore", category=UserWarning)
PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
PIPENV_VENDOR = os.sep.join([PIPENV_ROOT, "vendor"])
PIP_VENDOR = os.sep.join([PIPENV_ROOT, "patched", "pip", "_vendor"])

# Load patched pip instead of system pip
os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"
sys.path.insert(0, PIPENV_ROOT)
sys.path.insert(0, PIPENV_VENDOR)
sys.path.insert(0, PIP_VENDOR)

if os.name == "nt":
from pipenv.vendor import colorama
Expand All @@ -30,8 +18,6 @@
if not os.getenv("NO_COLOR") or no_color:
colorama.just_fix_windows_console()

from . import resolver # noqa: F401,E402
from .cli import cli # noqa: E402

if __name__ == "__main__":
cli()
2 changes: 2 additions & 0 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def run_open(state, module, *args, **kwargs):
@system_option
@option("--bare", is_flag=True, default=False, help="Minimal output.")
@sync_options
@site_packages_option
@pass_state
@pass_context
def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
Expand All @@ -687,6 +688,7 @@ def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
system=state.system,
extra_pip_args=state.installstate.extra_pip_args,
categories=state.installstate.categories,
site_packages=state.site_packages,
)
if retcode:
ctx.abort()
Expand Down
2 changes: 2 additions & 0 deletions pipenv/routines/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def do_sync(
deploy=False,
extra_pip_args=None,
categories=None,
site_packages=False,
):
# The lock file needs to exist because sync won't write to it.
if not project.lockfile_exists:
Expand All @@ -368,6 +369,7 @@ def do_sync(
deploy=deploy,
pypi_mirror=pypi_mirror,
clear=clear,
site_packages=site_packages,
)

# Install everything.
Expand Down

0 comments on commit 1cc03ea

Please sign in to comment.