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
Co-Authored-By: Tzu-ping Chung <[email protected]>
  • Loading branch information
KOLANICH and uranusjr committed Feb 1, 2021
1 parent 9d00fda commit 0179d62
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 @@
Fixed the bug preventing the use of --editable installs for setup.cfg-only setuptools-based projects.
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 io, os, sys, setuptools, tokenize;"
"f = tokenize.open(__file__) if os.path.exists(__file__) else io.StringIO('from setuptools import setup; setup()');"
"code=f.read().replace('\\r\\n', '\\n');"
"f.close();"
"exec(compile(code, __file__, 'exec'))"
Expand Down

0 comments on commit 0179d62

Please sign in to comment.