|
13 | 13 | _create_test_package_with_subdirectory, |
14 | 14 | create_basic_sdist_for_package, |
15 | 15 | create_basic_wheel_for_package, |
| 16 | + make_wheel, |
16 | 17 | need_svn, |
17 | 18 | requirements_file, |
18 | 19 | ) |
@@ -917,3 +918,26 @@ def test_config_settings_local_to_package( |
917 | 918 | assert "--verbose" not in simple3_args |
918 | 919 | simple2_args = simple2_sdist.args() |
919 | 920 | assert "--verbose" not in simple2_args |
| 921 | + |
| 922 | + |
| 923 | +def test_nonpep517_setuptools_import_failure(script: PipTestEnvironment) -> None: |
| 924 | + """Any import failures of `setuptools` should inform the user both that it's |
| 925 | + not pip's fault, but also exactly what went wrong in the import.""" |
| 926 | + # Install a poisoned version of 'setuptools' that fails to import. |
| 927 | + name = "setuptools_poisoned" |
| 928 | + module = """\ |
| 929 | +raise ImportError("this 'setuptools' was intentionally poisoned") |
| 930 | +""" |
| 931 | + path = make_wheel(name, "0.1.0", extra_files={"setuptools.py": module}).save_to_dir( |
| 932 | + script.scratch_path |
| 933 | + ) |
| 934 | + script.pip("install", "--no-index", path) |
| 935 | + |
| 936 | + result = script.pip_install_local("--no-use-pep517", "simple", expect_error=True) |
| 937 | + nice_message = ( |
| 938 | + "ERROR: Can not execute `setup.py`" |
| 939 | + " since setuptools failed to import in the build environment" |
| 940 | + ) |
| 941 | + exc_message = "ImportError: this 'setuptools' was intentionally poisoned" |
| 942 | + assert nice_message in result.stderr |
| 943 | + assert exc_message in result.stderr |
0 commit comments