Skip to content

Commit a6f8db0

Browse files
authored
Merge pull request #4980 from pypa/debt/4976-pbr-compat
Restore pbr compatibility
2 parents af8b322 + 05cf544 commit a6f8db0

File tree

5 files changed

+98
-38
lines changed

5 files changed

+98
-38
lines changed

newsfragments/4976.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restored select attributes in easy_install for temporary pbr compatibility.

setuptools/command/easy_install.py

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1+
import os
2+
import sys
3+
import types
4+
15
from setuptools import Command
26

7+
from .. import _scripts, warnings
8+
39

410
class easy_install(Command):
511
"""Stubbed command for temporary pbr compatibility."""
12+
13+
14+
def __getattr__(name):
15+
attr = getattr(
16+
types.SimpleNamespace(
17+
ScriptWriter=_scripts.ScriptWriter,
18+
sys_executable=os.environ.get(
19+
"__PYVENV_LAUNCHER__", os.path.normpath(sys.executable)
20+
),
21+
),
22+
name,
23+
)
24+
warnings.SetuptoolsDeprecationWarning.emit(
25+
summary="easy_install module is deprecated",
26+
details="Avoid accessing attributes of setuptools.command.easy_install.",
27+
due_date=(2025, 10, 31),
28+
see_url="https://github.com/pypa/setuptools/issues/4976",
29+
)
30+
return attr

setuptools/tests/fixtures.py

+43
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
from pathlib import Path
99

10+
import jaraco.path
1011
import path
1112
import pytest
1213

@@ -347,3 +348,45 @@ def create_setup_requires_package(
347348
make_package(foobar_path, distname, version)
348349

349350
return test_pkg
351+
352+
353+
@pytest.fixture
354+
def pbr_package(tmp_path, monkeypatch, venv):
355+
files = {
356+
"pyproject.toml": DALS(
357+
"""
358+
[build-system]
359+
requires = ["setuptools"]
360+
build-backend = "setuptools.build_meta"
361+
"""
362+
),
363+
"setup.py": DALS(
364+
"""
365+
__import__('setuptools').setup(
366+
pbr=True,
367+
setup_requires=["pbr"],
368+
)
369+
"""
370+
),
371+
"setup.cfg": DALS(
372+
"""
373+
[metadata]
374+
name = mypkg
375+
376+
[files]
377+
packages =
378+
mypkg
379+
"""
380+
),
381+
"mypkg": {
382+
"__init__.py": "",
383+
"hello.py": "print('Hello world!')",
384+
},
385+
"other": {"test.txt": "Another file in here."},
386+
}
387+
venv.run(["python", "-m", "pip", "install", "pbr"])
388+
prefix = tmp_path / 'mypkg'
389+
prefix.mkdir()
390+
jaraco.path.build(files, prefix=prefix)
391+
monkeypatch.setenv('PBR_VERSION', "0.42")
392+
return prefix
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import subprocess
2+
3+
4+
def test_pbr_integration(pbr_package, venv):
5+
"""Ensure pbr packages install."""
6+
cmd = [
7+
'python',
8+
'-m',
9+
'pip',
10+
'-v',
11+
'install',
12+
'--no-build-isolation',
13+
pbr_package,
14+
]
15+
venv.run(cmd, stderr=subprocess.STDOUT)
16+
out = venv.run(["python", "-c", "import mypkg.hello"])
17+
assert "Hello world!" in out

setuptools/tests/test_editable_install.py

+12-38
Original file line numberDiff line numberDiff line change
@@ -1068,45 +1068,19 @@ def test_compat_install(tmp_path, venv):
10681068
assert "cannot import name 'subpackage'" in out
10691069

10701070

1071-
def test_pbr_integration(tmp_path, venv, editable_opts):
1071+
def test_pbr_integration(pbr_package, venv, editable_opts):
10721072
"""Ensure editable installs work with pbr, issue #3500"""
1073-
files = {
1074-
"pyproject.toml": dedent(
1075-
"""\
1076-
[build-system]
1077-
requires = ["setuptools"]
1078-
build-backend = "setuptools.build_meta"
1079-
"""
1080-
),
1081-
"setup.py": dedent(
1082-
"""\
1083-
__import__('setuptools').setup(
1084-
pbr=True,
1085-
setup_requires=["pbr"],
1086-
)
1087-
"""
1088-
),
1089-
"setup.cfg": dedent(
1090-
"""\
1091-
[metadata]
1092-
name = mypkg
1093-
1094-
[files]
1095-
packages =
1096-
mypkg
1097-
"""
1098-
),
1099-
"mypkg": {
1100-
"__init__.py": "",
1101-
"hello.py": "print('Hello world!')",
1102-
},
1103-
"other": {"test.txt": "Another file in here."},
1104-
}
1105-
venv.run(["python", "-m", "pip", "install", "pbr"])
1106-
1107-
with contexts.environment(PBR_VERSION="0.42"):
1108-
install_project("mypkg", venv, tmp_path, files, *editable_opts)
1109-
1073+
cmd = [
1074+
'python',
1075+
'-m',
1076+
'pip',
1077+
'-v',
1078+
'install',
1079+
'--editable',
1080+
pbr_package,
1081+
*editable_opts,
1082+
]
1083+
venv.run(cmd, stderr=subprocess.STDOUT)
11101084
out = venv.run(["python", "-c", "import mypkg.hello"])
11111085
assert "Hello world!" in out
11121086

0 commit comments

Comments
 (0)