msg = "For best results, pass -X:Frames to enable call stack."
warnings.warn(msg)
return True
- res = inspect.getouterframes(run_frame)[2]
- caller, = res[:1]
- info = inspect.getframeinfo(caller)
- caller_module = caller.f_globals.get('__name__', '')
- return (
- caller_module == 'distutils.dist'
- and info.function == 'run_commands'
- )
+
+ frames = inspect.getouterframes(run_frame)
+ for frame in frames[2:4]:
+ caller, = frame[:1]
+ info = inspect.getframeinfo(caller)
+ caller_module = caller.f_globals.get('__name__', '')
+
+ if caller_module == "setuptools.dist" and info.function == "run_command":
+ # Starting from v61.0.0 setuptools overwrites dist.run_command
+ continue
+
+ return (
+ caller_module == 'distutils.dist'
+ and info.function == 'run_commands'
+ )
def do_egg_install(self):
run_setup('setup.py', ['bdist_egg'])
+class TestInstallRequires:
+ def test_setup_install_includes_dependencies(self, tmp_path, mock_index):
+ """
+ When ``python setup.py install`` is called directly, it will use easy_install
+ to fetch dependencies.
+ """
+ # TODO: Remove these tests once `setup.py install` is completely removed
+ project_root = tmp_path / "project"
+ project_root.mkdir(exist_ok=True)
+ install_root = tmp_path / "install"
+ install_root.mkdir(exist_ok=True)
+
+ self.create_project(project_root)
+ cmd = [
+ sys.executable,
+ '-c', '__import__("setuptools").setup()',
+ 'install',
+ '--install-base', str(install_root),
+ '--install-lib', str(install_root),
+ '--install-headers', str(install_root),
+ '--install-scripts', str(install_root),
+ '--install-data', str(install_root),
+ '--install-purelib', str(install_root),
+ '--install-platlib', str(install_root),
+ ]
+ env = {"PYTHONPATH": str(install_root), "__EASYINSTALL_INDEX": mock_index.url}
+ with pytest.raises(subprocess.CalledProcessError) as exc_info:
+ subprocess.check_output(
+ cmd, cwd=str(project_root), env=env, stderr=subprocess.STDOUT, text=True
+ )
+ try:
+ assert '/does-not-exist/' in {r.path for r in mock_index.requests}
+ assert next(
+ line
+ for line in exc_info.value.output.splitlines()
+ if "not find suitable distribution for" in line
+ and "does-not-exist" in line
+ )
+ except Exception:
+ if "failed to get random numbers" in exc_info.value.output:
+ pytest.xfail(f"{sys.platform} failure - {exc_info.value.output}")
+ raise
+
+ def create_project(self, root):
+ config = """
+ [metadata]
+ name = project
+ version = 42
+
+ [options]
+ install_requires = does-not-exist
+ py_modules = mod
+ """
+ (root / 'setup.cfg').write_text(DALS(config), encoding="utf-8")
+ (root / 'mod.py').touch()
+
+
class TestSetupRequires:
def test_setup_requires_honors_fetch_params(self, mock_index, monkeypatch):
with contexts.environment(PYTHONPATH=temp_install_dir):
cmd = [
sys.executable,
- '-m', 'setup',
+ '-c', '__import__("setuptools").setup()',
'easy_install',
'--index-url', mock_index.url,
'--exclude-scripts',