Files
pipenv/pipenv/__init__.py
T
Matt Davis 6ac1451ec8 stop using requirementslib models (#5793)
* Move away from requirementslib models

* Revise test since PEP-440 does not support wildcard versions but does support equivalent compatible release specifiers.

* simplify and remove dead code

* Ensure the os_name marker is AND with the other markers.

* Move what we still need from requirementslib into the pipenv utils and stop vendoring it.

* Remove requirementslib.

* force upgrade of virtualenv for python 3.12

* remove virtualenv-clone

* Update vcs specifiers documentation; infer name from specific pip line formats where possible.

* Provide helpful text and error for recently removed commands

* Set the right log levels and verbosity to show users the errors generated by pip resolver when supplying -v flag

* Fix the collection of all matching package hashes for non-pypi indexes.  Plus lesson from testing torch which contains local identifiers.
2023-08-19 16:36:52 -04:00

58 lines
1.7 KiB
Python

import importlib.util
import os
import sys
import warnings
# This has to come before imports of pipenv
PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
PIP_ROOT = os.sep.join([PIPENV_ROOT, "patched", "pip"])
sys.path.insert(0, PIPENV_ROOT)
sys.path.insert(0, PIP_ROOT)
# Load patched pip instead of system pip
os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"
def _ensure_modules():
# Can be removed when we drop pydantic
spec = importlib.util.spec_from_file_location(
"typing_extensions",
location=os.path.join(
os.path.dirname(__file__), "patched", "pip", "_vendor", "typing_extensions.py"
),
)
typing_extensions = importlib.util.module_from_spec(spec)
sys.modules["typing_extensions"] = typing_extensions
spec.loader.exec_module(typing_extensions)
# Ensure when pip gets invoked it uses our patched version
spec = importlib.util.spec_from_file_location(
"pip",
location=os.path.join(os.path.dirname(__file__), "patched", "pip", "__init__.py"),
)
pip = importlib.util.module_from_spec(spec)
sys.modules["pip"] = pip
spec.loader.exec_module(pip)
_ensure_modules()
from pipenv.__version__ import __version__ # noqa
from pipenv.cli import cli # noqa
from pipenv.patched.pip._vendor.urllib3.exceptions import DependencyWarning # noqa
warnings.filterwarnings("ignore", category=DependencyWarning)
warnings.filterwarnings("ignore", category=ResourceWarning)
warnings.filterwarnings("ignore", category=UserWarning)
if os.name == "nt":
from pipenv.vendor import colorama
no_color = False
if not os.getenv("NO_COLOR") or no_color:
colorama.just_fix_windows_console()
if __name__ == "__main__":
cli()