File tree 3 files changed +18
-2
lines changed
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 10
10
# The following comment should be removed at some point in the future.
11
11
# mypy: strict-optional=False
12
12
13
+ import importlib .util
13
14
import logging
14
15
import os
15
16
import textwrap
@@ -775,6 +776,13 @@ def _handle_no_use_pep517(
775
776
"""
776
777
raise_option_error (parser , option = option , msg = msg )
777
778
779
+ # If user doesn't wish to use pep517, we check if setuptools is installed
780
+ # and raise error if it is not.
781
+ if not importlib .util .find_spec ("setuptools" ):
782
+ msg = """It is not possible to use --no-use-pep517 without setuptools
783
+ installed."""
784
+ raise_option_error (parser , option = option , msg = msg )
785
+
778
786
# Otherwise, --no-use-pep517 was passed via the command-line.
779
787
parser .values .use_pep517 = False
780
788
Original file line number Diff line number Diff line change
1
+ import importlib .util
1
2
import os
2
3
from collections import namedtuple
3
4
from typing import Any , List , Optional
@@ -89,9 +90,15 @@ def load_pyproject_toml(
89
90
90
91
# If we haven't worked out whether to use PEP 517 yet,
91
92
# 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
93
100
elif use_pep517 is None :
94
- use_pep517 = has_pyproject
101
+ use_pep517 = has_pyproject or not importlib . util . find_spec ( "setuptools" )
95
102
96
103
# At this point, we know whether we're going to use PEP 517.
97
104
assert use_pep517 is not None
You can’t perform that action at this time.
0 commit comments