diff --git a/news/8214.bugfix b/news/8214.bugfix new file mode 100644 index 00000000000..1dc5cd79d11 --- /dev/null +++ b/news/8214.bugfix @@ -0,0 +1 @@ +Fix installing packages which have a pyproject.toml when enum34 is installed. diff --git a/news/8214.removal b/news/8214.removal new file mode 100644 index 00000000000..31f3089493d --- /dev/null +++ b/news/8214.removal @@ -0,0 +1,2 @@ +Removes the ability to run pip via ``python src/pip/`` from a checkout without +setting PYTHONPATH first. diff --git a/src/pip/__main__.py b/src/pip/__main__.py index 7c2505fa5bd..a529758b395 100644 --- a/src/pip/__main__.py +++ b/src/pip/__main__.py @@ -18,7 +18,10 @@ # Resulting path is the name of the wheel itself # Add that to sys.path so we can import pip path = os.path.dirname(os.path.dirname(__file__)) - sys.path.insert(0, path) + # __package__ could have also been the empty string if pip was invoked + # with the path to the pip directory. ie: as python /path/to/pip/. + if path.endswith('.whl'): + sys.path.insert(0, path) from pip._internal.cli.main import main as _main # isort:skip # noqa