Skip to content

Commit

Permalink
Fixed --editable install for setuptools projects without setup.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Feb 1, 2021
1 parent 9d00fda commit 99b878a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/9547.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When --editable install is used for setup.cfg-only setuptools-based projects it doesn't work.
7 changes: 4 additions & 3 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ def parse_editable(editable_req):
url_no_extras, extras = _strip_extras(url)

if os.path.isdir(url_no_extras):
if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
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')):
msg = (
'File "setup.py" not found. Directory cannot be installed '
'File "setup.py" or "setup.cfg" not found. Directory cannot be installed '
'in editable mode: {}'.format(os.path.abspath(url_no_extras))
)
pyproject_path = make_pyproject_path(url_no_extras)
if os.path.isfile(pyproject_path):
msg += (
'\n(A "pyproject.toml" file was found, but editable '
'mode currently requires a setup.py based build.)'
'mode currently requires a setuptools-based build'
' ("setup.py" or "setup.cfg" or both).)'
)
raise InstallationError(msg)

Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/utils/setuptools_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# invoking via the shim. This avoids e.g. the following manifest_maker
# warning: "warning: manifest_maker: standard file '-c' not found".
_SETUPTOOLS_SHIM = (
"import sys, setuptools, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"
"f=getattr(tokenize, 'open', open)(__file__);"
"import sys, setuptools.build_meta, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"
"f = setuptools.build_meta._open_setup_script(__file__) if hasattr(setuptools.build_meta, '_open_setup_script') else getattr(tokenize, 'open', open)(__file__);"
"code=f.read().replace('\\r\\n', '\\n');"
"f.close();"
"exec(compile(code, __file__, 'exec'))"
Expand Down

0 comments on commit 99b878a

Please sign in to comment.