@@ -448,6 +448,63 @@ def test_bdist_egg_available_on_distutils_pkg(self, distutils_package):
448448 run_setup ('setup.py' , ['bdist_egg' ])
449449
450450
451+ class TestInstallRequires :
452+ def test_setup_install_includes_dependencies (self , tmp_path , mock_index ):
453+ """
454+ When ``python setup.py install`` is called directly, it will use easy_install
455+ to fetch dependencies.
456+ """
457+ # TODO: Remove these tests once `setup.py install` is completely removed
458+ project_root = tmp_path / "project"
459+ project_root .mkdir (exist_ok = True )
460+ install_root = tmp_path / "install"
461+ install_root .mkdir (exist_ok = True )
462+
463+ self .create_project (project_root )
464+ cmd = [
465+ sys .executable ,
466+ '-c' , '__import__("setuptools").setup()' ,
467+ 'install' ,
468+ '--install-base' , str (install_root ),
469+ '--install-lib' , str (install_root ),
470+ '--install-headers' , str (install_root ),
471+ '--install-scripts' , str (install_root ),
472+ '--install-data' , str (install_root ),
473+ '--install-purelib' , str (install_root ),
474+ '--install-platlib' , str (install_root ),
475+ ]
476+ env = {"PYTHONPATH" : str (install_root ), "__EASYINSTALL_INDEX" : mock_index .url }
477+ with pytest .raises (subprocess .CalledProcessError ) as exc_info :
478+ subprocess .check_output (
479+ cmd , cwd = str (project_root ), env = env , stderr = subprocess .STDOUT , text = True
480+ )
481+ try :
482+ assert '/does-not-exist/' in {r .path for r in mock_index .requests }
483+ assert next (
484+ line
485+ for line in exc_info .value .output .splitlines ()
486+ if "not find suitable distribution for" in line
487+ and "does-not-exist" in line
488+ )
489+ except Exception :
490+ if "failed to get random numbers" in exc_info .value .output :
491+ pytest .xfail (f"{ sys .platform } failure - { exc_info .value .output } " )
492+ raise
493+
494+ def create_project (self , root ):
495+ config = """
496+ [metadata]
497+ name = project
498+ version = 42
499+
500+ [options]
501+ install_requires = does-not-exist
502+ py_modules = mod
503+ """
504+ (root / 'setup.cfg' ).write_text (DALS (config ), encoding = "utf-8" )
505+ (root / 'mod.py' ).touch ()
506+
507+
451508class TestSetupRequires :
452509
453510 def test_setup_requires_honors_fetch_params (self , mock_index , monkeypatch ):
@@ -466,7 +523,7 @@ def test_setup_requires_honors_fetch_params(self, mock_index, monkeypatch):
466523 with contexts .environment (PYTHONPATH = temp_install_dir ):
467524 cmd = [
468525 sys .executable ,
469- '-m ' , 'setup' ,
526+ '-c ' , '__import__("setuptools"). setup() ' ,
470527 'easy_install' ,
471528 '--index-url' , mock_index .url ,
472529 '--exclude-scripts' ,
0 commit comments