Skip to content

Commit 99b878a

Browse files
committed
Fixed --editable install for setuptools projects without setup.py.
1 parent 9d00fda commit 99b878a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Diff for: news/9547.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When --editable install is used for setup.cfg-only setuptools-based projects it doesn't work.

Diff for: src/pip/_internal/req/constructors.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,17 @@ def parse_editable(editable_req):
8282
url_no_extras, extras = _strip_extras(url)
8383

8484
if os.path.isdir(url_no_extras):
85-
if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
85+
if not os.path.exists(os.path.join(url_no_extras, 'setup.py')) and not os.path.exists(os.path.join(url_no_extras, 'setup.cfg')):
8686
msg = (
87-
'File "setup.py" not found. Directory cannot be installed '
87+
'File "setup.py" or "setup.cfg" not found. Directory cannot be installed '
8888
'in editable mode: {}'.format(os.path.abspath(url_no_extras))
8989
)
9090
pyproject_path = make_pyproject_path(url_no_extras)
9191
if os.path.isfile(pyproject_path):
9292
msg += (
9393
'\n(A "pyproject.toml" file was found, but editable '
94-
'mode currently requires a setup.py based build.)'
94+
'mode currently requires a setuptools-based build'
95+
' ("setup.py" or "setup.cfg" or both).)'
9596
)
9697
raise InstallationError(msg)
9798

Diff for: src/pip/_internal/utils/setuptools_build.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# invoking via the shim. This avoids e.g. the following manifest_maker
1313
# warning: "warning: manifest_maker: standard file '-c' not found".
1414
_SETUPTOOLS_SHIM = (
15-
"import sys, setuptools, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"
16-
"f=getattr(tokenize, 'open', open)(__file__);"
15+
"import sys, setuptools.build_meta, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"
16+
"f = setuptools.build_meta._open_setup_script(__file__) if hasattr(setuptools.build_meta, '_open_setup_script') else getattr(tokenize, 'open', open)(__file__);"
1717
"code=f.read().replace('\\r\\n', '\\n');"
1818
"f.close();"
1919
"exec(compile(code, __file__, 'exec'))"

0 commit comments

Comments
 (0)