From c4d780731ac1331667a46f8de3a80fbff33db2c7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 22 Jan 2022 20:45:08 -0500 Subject: Rely on pip_run.launch to install sitecustomize. --- setup.cfg | 1 + setuptools/tests/test_develop.py | 23 ++++------------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/setup.cfg b/setup.cfg index b83d3763..0dc90438 100644 --- a/setup.cfg +++ b/setup.cfg @@ -65,6 +65,7 @@ testing = jaraco.path>=3.2.0 build[virtualenv] filelock>=3.4.0 + pip_run>=8.8 testing-integration = pytest diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 1aeb7ffe..c52072ac 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -6,11 +6,11 @@ import sys import subprocess import platform import pathlib -import textwrap from setuptools.command import test import pytest +import pip_run.launch from setuptools.command.develop import develop from setuptools.dist import Distribution @@ -166,21 +166,6 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp) - @staticmethod - def install_workaround(site_packages): - site_packages.mkdir(parents=True) - sc = site_packages / 'sitecustomize.py' - sc.write_text( - textwrap.dedent( - """ - import site - import pathlib - here = pathlib.Path(__file__).parent - site.addsitedir(str(here)) - """ - ).lstrip() - ) - @pytest.mark.xfail( platform.python_implementation() == 'PyPy', reason="Workaround fails on PyPy (why?)", @@ -190,7 +175,6 @@ class TestNamespaces: Editable install to a prefix should be discoverable. """ prefix = tmp_path / 'prefix' - prefix.mkdir() # figure out where pip will likely install the package site_packages = prefix / next( @@ -198,9 +182,10 @@ class TestNamespaces: for path in sys.path if 'site-packages' in path and path.startswith(sys.prefix) ) + site_packages.mkdir(parents=True) - # install the workaround - self.install_workaround(site_packages) + # install workaround + pip_run.launch.inject_sitecustomize(str(site_packages)) env = dict(os.environ, PYTHONPATH=str(site_packages)) cmd = [ -- cgit v1.2.1