Skip to content

Commit 8dbf77f

Browse files
committed
Disable import of setuptools for sdist builds. Fixes pypa#4264 and pypa/setuptools#951.
1 parent 022248f commit 8dbf77f

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

CHANGES.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
** 9.0.2 (2017-02-??) **
2+
3+
* Only check that setuptools appears to be installed but no longer test
4+
the import before invoking a sdist build (:issue:`4264`).
5+
6+
17
**9.0.1 (2016-11-06)**
28

39
* Correct the deprecation message when not specifying a --format so that it

pip/req/req_install.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,10 @@ def setup_py_dir(self):
383383
@property
384384
def setup_py(self):
385385
assert self.source_dir, "No source dir for %s" % self
386-
try:
387-
import setuptools # noqa
388-
except ImportError:
389-
if get_installed_version('setuptools') is None:
390-
add_msg = "Please install setuptools."
391-
else:
392-
add_msg = traceback.format_exc()
393-
# Setuptools is not available
394-
raise InstallationError(
395-
"Could not import setuptools which is required to "
396-
"install from a source distribution.\n%s" % add_msg
386+
if get_installed_version('setuptools') is None:
387+
raise InstallationError("Setuptools is required to install "
388+
"from a source distribution, but none was found. Please "
389+
"install setuptools."
397390
)
398391

399392
setup_py = os.path.join(self.setup_py_dir, 'setup.py')

tests/functional/test_install.py

+2-27
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,13 @@ def test_without_setuptools(script, data):
2828
expect_error=True,
2929
)
3030
assert (
31-
"Could not import setuptools which is required to install from a "
32-
"source distribution."
31+
"Setuptools is required to install from a source distribution, but "
32+
"none was found."
3333
in result.stderr
3434
)
3535
assert "Please install setuptools" in result.stderr
3636

3737

38-
def test_with_setuptools_and_import_error(script, data):
39-
# Make sure we get an ImportError while importing setuptools
40-
setuptools_init_path = script.site_packages_path.join(
41-
"setuptools", "__init__.py")
42-
with open(setuptools_init_path, 'a') as f:
43-
f.write('\nraise ImportError("toto")')
44-
45-
result = script.run(
46-
"python", "-c",
47-
"import pip; pip.main(["
48-
"'install', "
49-
"'INITools==0.2', "
50-
"'-f', '%s', "
51-
"'--no-binary=:all:'])" % data.packages,
52-
expect_error=True,
53-
)
54-
assert (
55-
"Could not import setuptools which is required to install from a "
56-
"source distribution."
57-
in result.stderr
58-
)
59-
assert "Traceback " in result.stderr
60-
assert "ImportError: toto" in result.stderr
61-
62-
6338
def test_pip_second_command_line_interface_works(script, data):
6439
"""
6540
Check if ``pip<PYVERSION>`` commands behaves equally

0 commit comments

Comments
 (0)