From 437b890ea8151c7d82fe03d08927232eb75a03fc Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 4 Apr 2022 01:54:10 +0100 Subject: [PATCH 1/3] Fix error with test_easy_install --- setuptools/tests/test_easy_install.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 85f528db18..53a81f2db3 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1184,16 +1184,19 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmp_path) # it will `makedirs("/home/user/.pyenv/versions/3.9.10 /home/user/.pyenv/versions/3.9.10/lib /home/user/.pyenv/versions/3.9.10/lib/python3.9 /home/user/.pyenv/versions/3.9.10/lib/python3.9/lib-dynload")`` # noqa: E501 # 2. We are going to force `site` to update site.USER_BASE and site.USER_SITE # To point inside our new home - monkeypatch.setenv('HOME', str(tmp_path / 'home')) + monkeypatch.setenv('HOME', str(tmp_path / '.home')) monkeypatch.setattr('site.USER_BASE', None) monkeypatch.setattr('site.USER_SITE', None) user_site = Path(site.getusersitepackages()) user_site.mkdir(parents=True, exist_ok=True) - sys_prefix = (tmp_path / 'sys_prefix') + sys_prefix = (tmp_path / '.sys_prefix') sys_prefix.mkdir(parents=True, exist_ok=True) monkeypatch.setattr('sys.prefix', str(sys_prefix)) + setup_script = "__import__('setuptools').setup(name='aproj', version=42)\n" + (tmp_path / "setup.py").write_text(setup_script, encoding="utf-8") + # == Sanity check == assert list(sys_prefix.glob("*")) == [] assert list(user_site.glob("*")) == [] @@ -1208,4 +1211,4 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmp_path) installed = {f.name for f in user_site.glob("*")} # sometimes easy-install.pth is created and sometimes not installed = installed - {"easy-install.pth"} - assert installed == {'UNKNOWN.egg-link'} + assert installed == {'aproj.egg-link'} From 9cb8a419796f29068f0a34086e104a60979eaa52 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 4 Apr 2022 08:06:52 +0100 Subject: [PATCH 2/3] Be explicit about packages --- setuptools/tests/test_easy_install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 53a81f2db3..dfe8b91154 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1194,7 +1194,9 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmp_path) sys_prefix.mkdir(parents=True, exist_ok=True) monkeypatch.setattr('sys.prefix', str(sys_prefix)) - setup_script = "__import__('setuptools').setup(name='aproj', version=42)\n" + setup_script = ( + "__import__('setuptools').setup(name='aproj', version=42, packages=[])\n" + ) (tmp_path / "setup.py").write_text(setup_script, encoding="utf-8") # == Sanity check == From ec62173700ea7121e8f3d0707e3af20a6b60e92b Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 4 Apr 2022 08:07:11 +0100 Subject: [PATCH 3/3] Attempt to fix problems on windows --- setuptools/tests/test_easy_install.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index dfe8b91154..726f9fda5a 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1185,6 +1185,8 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmp_path) # 2. We are going to force `site` to update site.USER_BASE and site.USER_SITE # To point inside our new home monkeypatch.setenv('HOME', str(tmp_path / '.home')) + monkeypatch.setenv('USERPROFILE', str(tmp_path / '.home')) + monkeypatch.setenv('APPDATA', str(tmp_path / '.home')) monkeypatch.setattr('site.USER_BASE', None) monkeypatch.setattr('site.USER_SITE', None) user_site = Path(site.getusersitepackages())