1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Fix in-site-packages patch for user install tests

This commit is contained in:
Tzu-ping Chung 2021-11-22 22:52:07 +08:00
parent 6ed6aa819f
commit 496343ead0
2 changed files with 6 additions and 9 deletions

View file

@ -16,18 +16,15 @@ from tests.lib.venv import VirtualEnvironment
def _patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
# Since the tests are run from a virtualenv, and to avoid the "Will not
# install to the usersite because it will lack sys.path precedence..."
# error: Monkey patch `pip._internal.req.req_install.dist_in_site_packages`
# and `pip._internal.utils.misc.dist_in_site_packages`
# so it's possible to install a conflicting distribution in the user site.
# error: Monkey patch the Distribution class so it's possible to install a
# conflicting distribution in the user site.
virtualenv.sitecustomize = textwrap.dedent(
"""
def dist_in_site_packages(dist):
return False
from pip._internal.req import req_install
from pip._internal.utils import misc
req_install.dist_in_site_packages = dist_in_site_packages
misc.dist_in_site_packages = dist_in_site_packages
from pip._internal.metadata.base import BaseDistribution
BaseDistribution.in_site_packages = property(dist_in_site_packages)
"""
)

View file

@ -135,8 +135,8 @@ def patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
def dist_in_site_packages(dist):
return False
from pip._internal.utils import misc
misc.dist_in_site_packages = dist_in_site_packages
from pip._internal.metadata.base import BaseDistribution
BaseDistribution.in_site_packages = property(dist_in_site_packages)
"""
)