File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1+ Fallback to pep517 if setup.py is present and setuptools cannot be imported
Original file line number Diff line number Diff line change 1010# The following comment should be removed at some point in the future.
1111# mypy: strict-optional=False
1212
13+ import importlib .util
1314import os
1415import textwrap
1516import warnings
@@ -774,6 +775,13 @@ def _handle_no_use_pep517(
774775 """
775776 raise_option_error (parser , option = option , msg = msg )
776777
778+ # If user doesn't wish to use pep517, we check if setuptools is installed
779+ # and raise error if it is not.
780+ if not importlib .util .find_spec ("setuptools" ):
781+ msg = """It is not possible to use --no-use-pep517 without setuptools
782+ installed."""
783+ raise_option_error (parser , option = option , msg = msg )
784+
777785 # Otherwise, --no-use-pep517 was passed via the command-line.
778786 parser .values .use_pep517 = False
779787
Original file line number Diff line number Diff line change 1+ import importlib .util
12import os
23from collections import namedtuple
34from typing import Any , List , Optional
@@ -89,9 +90,15 @@ def load_pyproject_toml(
8990
9091 # If we haven't worked out whether to use PEP 517 yet,
9192 # and the user hasn't explicitly stated a preference,
92- # we do so if the project has a pyproject.toml file.
93+ # we do so if the project has a pyproject.toml file
94+ # or if we cannot import setuptools.
95+
96+ # We fallback to PEP 517 when without setuptools,
97+ # so setuptools can be installed as a default build backend.
98+ # For more info see:
99+ # https://discuss.python.org/t/pip-without-setuptools-could-the-experience-be-improved/11810/9
93100 elif use_pep517 is None :
94- use_pep517 = has_pyproject
101+ use_pep517 = has_pyproject or not importlib . util . find_spec ( "setuptools" )
95102
96103 # At this point, we know whether we're going to use PEP 517.
97104 assert use_pep517 is not None
You can’t perform that action at this time.
0 commit comments