Skip to content

Commit 95640b8

Browse files
authored
Merge pull request #12127 from uranusjr/no-setuptools-in-tests
2 parents 07049fe + 5d0a464 commit 95640b8

File tree

8 files changed

+82
-26
lines changed

8 files changed

+82
-26
lines changed

.github/workflows/ci.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
- run: git diff --exit-code
9292

9393
tests-unix:
94-
name: tests / ${{ matrix.python }} / ${{ matrix.os }}
94+
name: tests / ${{ matrix.python.key || matrix.python }} / ${{ matrix.os }}
9595
runs-on: ${{ matrix.os }}-latest
9696

9797
needs: [packaging, determine-changes]
@@ -109,12 +109,14 @@ jobs:
109109
- "3.9"
110110
- "3.10"
111111
- "3.11"
112+
- key: "3.12"
113+
full: "3.12-dev"
112114

113115
steps:
114116
- uses: actions/checkout@v3
115117
- uses: actions/setup-python@v4
116118
with:
117-
python-version: ${{ matrix.python }}
119+
python-version: ${{ matrix.python.full || matrix.python }}
118120

119121
- name: Install Ubuntu dependencies
120122
if: matrix.os == 'Ubuntu'
@@ -129,12 +131,12 @@ jobs:
129131
# Main check
130132
- name: Run unit tests
131133
run: >-
132-
nox -s test-${{ matrix.python }} --
134+
nox -s test-${{ matrix.python.key || matrix.python }} --
133135
-m unit
134136
--verbose --numprocesses auto --showlocals
135137
- name: Run integration tests
136138
run: >-
137-
nox -s test-${{ matrix.python }} --
139+
nox -s test-${{ matrix.python.key || matrix.python }} --
138140
-m integration
139141
--verbose --numprocesses auto --showlocals
140142
--durations=5

docs/html/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ $ pip install --upgrade pip
103103
The current version of pip works on:
104104

105105
- Windows, Linux and MacOS.
106-
- CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.
106+
- CPython 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, and latest PyPy3.
107107

108108
pip is tested to work on the latest patch version of the Python interpreter,
109109
for each of the minor versions listed above. Previous patch versions are

noxfile.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def should_update_common_wheels() -> bool:
6767
# -----------------------------------------------------------------------------
6868
# Development Commands
6969
# -----------------------------------------------------------------------------
70-
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"])
70+
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"])
7171
def test(session: nox.Session) -> None:
7272
# Get the common wheels.
7373
if should_update_common_wheels():
@@ -89,6 +89,7 @@ def test(session: nox.Session) -> None:
8989
shutil.rmtree(sdist_dir, ignore_errors=True)
9090

9191
# fmt: off
92+
session.install("setuptools")
9293
session.run(
9394
"python", "setup.py", "sdist", "--formats=zip", "--dist-dir", sdist_dir,
9495
silent=True,
@@ -351,6 +352,7 @@ def build_dists(session: nox.Session) -> List[str]:
351352
)
352353

353354
session.log("# Build distributions")
355+
session.install("setuptools", "wheel")
354356
session.run("python", "setup.py", "sdist", "bdist_wheel", silent=True)
355357
produced_dists = glob.glob("dist/*")
356358

tests/conftest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
if TYPE_CHECKING:
5050
from typing import Protocol
5151

52-
from wsgi import WSGIApplication
52+
from _typeshed.wsgi import WSGIApplication
5353
else:
5454
# TODO: Protocol was introduced in Python 3.8. Remove this branch when
5555
# dropping support for Python 3.7.
@@ -645,7 +645,12 @@ def pip(self, *args: Union[str, Path]) -> InMemoryPipResult:
645645
try:
646646
returncode = pip_entry_point([os.fspath(a) for a in args])
647647
except SystemExit as e:
648-
returncode = e.code or 0
648+
if isinstance(e.code, int):
649+
returncode = e.code
650+
elif e.code:
651+
returncode = 1
652+
else:
653+
returncode = 0
649654
finally:
650655
sys.stdout = orig_stdout
651656
return InMemoryPipResult(returncode, stdout.getvalue())

tests/functional/test_build_env.py

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
from textwrap import dedent
34
from typing import Optional
45

@@ -203,6 +204,31 @@ def test_build_env_overlay_prefix_has_priority(script: PipTestEnvironment) -> No
203204
assert result.stdout.strip() == "2.0", str(result)
204205

205206

207+
if sys.version_info < (3, 12):
208+
BUILD_ENV_ERROR_DEBUG_CODE = r"""
209+
from distutils.sysconfig import get_python_lib
210+
print(
211+
f'imported `pkg` from `{pkg.__file__}`',
212+
file=sys.stderr)
213+
print('system sites:\n ' + '\n '.join(sorted({
214+
get_python_lib(plat_specific=0),
215+
get_python_lib(plat_specific=1),
216+
})), file=sys.stderr)
217+
"""
218+
else:
219+
BUILD_ENV_ERROR_DEBUG_CODE = r"""
220+
from sysconfig import get_paths
221+
paths = get_paths()
222+
print(
223+
f'imported `pkg` from `{pkg.__file__}`',
224+
file=sys.stderr)
225+
print('system sites:\n ' + '\n '.join(sorted({
226+
paths['platlib'],
227+
paths['purelib'],
228+
})), file=sys.stderr)
229+
"""
230+
231+
206232
@pytest.mark.usefixtures("enable_user_site")
207233
def test_build_env_isolation(script: PipTestEnvironment) -> None:
208234
# Create dummy `pkg` wheel.
@@ -231,26 +257,17 @@ def test_build_env_isolation(script: PipTestEnvironment) -> None:
231257
run_with_build_env(
232258
script,
233259
"",
234-
r"""
235-
from distutils.sysconfig import get_python_lib
260+
f"""
236261
import sys
237262
238263
try:
239264
import pkg
240265
except ImportError:
241266
pass
242267
else:
243-
print(
244-
f'imported `pkg` from `{pkg.__file__}`',
245-
file=sys.stderr)
246-
print('system sites:\n ' + '\n '.join(sorted({
247-
get_python_lib(plat_specific=0),
248-
get_python_lib(plat_specific=1),
249-
})), file=sys.stderr)
250-
print('sys.path:\n ' + '\n '.join(sys.path), file=sys.stderr)
268+
{BUILD_ENV_ERROR_DEBUG_CODE}
269+
print('sys.path:\\n ' + '\\n '.join(sys.path), file=sys.stderr)
251270
sys.exit(1)
252-
"""
253-
f"""
254271
# second check: direct check of exclusion of system site packages
255272
import os
256273

tests/functional/test_install.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -848,14 +848,18 @@ def test_editable_install__local_dir_no_setup_py(
848848
)
849849

850850

851+
@pytest.mark.skipif(
852+
sys.version_info >= (3, 12),
853+
reason="Setuptools<64 does not support Python 3.12+",
854+
)
851855
@pytest.mark.network
852-
def test_editable_install__local_dir_no_setup_py_with_pyproject(
856+
def test_editable_install_legacy__local_dir_no_setup_py_with_pyproject(
853857
script: PipTestEnvironment,
854858
) -> None:
855859
"""
856-
Test installing in editable mode from a local directory with no setup.py
857-
but that does have pyproject.toml with a build backend that does not support
858-
the build_editable hook.
860+
Test installing in legacy editable mode from a local directory with no
861+
setup.py but that does have pyproject.toml with a build backend that does
862+
not support the build_editable hook.
859863
"""
860864
local_dir = script.scratch_path.joinpath("temp")
861865
local_dir.mkdir()
@@ -1383,8 +1387,14 @@ def test_install_editable_with_prefix_setup_py(script: PipTestEnvironment) -> No
13831387
_test_install_editable_with_prefix(script, {"setup.py": setup_py})
13841388

13851389

1390+
@pytest.mark.skipif(
1391+
sys.version_info >= (3, 12),
1392+
reason="Setuptools<64 does not support Python 3.12+",
1393+
)
13861394
@pytest.mark.network
1387-
def test_install_editable_with_prefix_setup_cfg(script: PipTestEnvironment) -> None:
1395+
def test_install_editable_legacy_with_prefix_setup_cfg(
1396+
script: PipTestEnvironment,
1397+
) -> None:
13881398
setup_cfg = """[metadata]
13891399
name = pkga
13901400
version = 0.1

tests/functional/test_uninstall.py

+20
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def test_basic_uninstall(script: PipTestEnvironment) -> None:
3737
assert_all_changes(result, result2, [script.venv / "build", "cache"])
3838

3939

40+
@pytest.mark.skipif(
41+
sys.version_info >= (3, 12),
42+
reason="distutils is no longer available in Python 3.12+",
43+
)
4044
def test_basic_uninstall_distutils(script: PipTestEnvironment) -> None:
4145
"""
4246
Test basic install and uninstall.
@@ -68,6 +72,10 @@ def test_basic_uninstall_distutils(script: PipTestEnvironment) -> None:
6872
) in result.stderr
6973

7074

75+
@pytest.mark.skipif(
76+
sys.version_info >= (3, 12),
77+
reason="Setuptools<64 does not support Python 3.12+",
78+
)
7179
@pytest.mark.network
7280
def test_basic_uninstall_with_scripts(script: PipTestEnvironment) -> None:
7381
"""
@@ -101,6 +109,10 @@ def test_uninstall_invalid_parameter(
101109
assert expected_message in result.stderr
102110

103111

112+
@pytest.mark.skipif(
113+
sys.version_info >= (3, 12),
114+
reason="Setuptools<64 does not support Python 3.12+",
115+
)
104116
@pytest.mark.network
105117
def test_uninstall_easy_install_after_import(script: PipTestEnvironment) -> None:
106118
"""
@@ -126,6 +138,10 @@ def test_uninstall_easy_install_after_import(script: PipTestEnvironment) -> None
126138
)
127139

128140

141+
@pytest.mark.skipif(
142+
sys.version_info >= (3, 12),
143+
reason="Setuptools<64 does not support Python 3.12+",
144+
)
129145
@pytest.mark.network
130146
def test_uninstall_trailing_newline(script: PipTestEnvironment) -> None:
131147
"""
@@ -337,6 +353,10 @@ def test_uninstall_console_scripts_uppercase_name(script: PipTestEnvironment) ->
337353
assert not script_name.exists()
338354

339355

356+
@pytest.mark.skipif(
357+
sys.version_info >= (3, 12),
358+
reason="Setuptools<64 does not support Python 3.12+",
359+
)
340360
@pytest.mark.network
341361
def test_uninstall_easy_installed_console_scripts(script: PipTestEnvironment) -> None:
342362
"""

tests/lib/venv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _create(self, clear: bool = False) -> None:
124124
)
125125
elif self._venv_type == "venv":
126126
builder = _venv.EnvBuilder()
127-
context = builder.ensure_directories(self.location)
127+
context = builder.ensure_directories(os.fspath(self.location))
128128
builder.create_configuration(context)
129129
builder.setup_python(context)
130130
self.site.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)