Skip to content

Commit bcc23a2

Browse files
committed
Implement the editable debugging tips as a reference to the docs.
1 parent aa911c6 commit bcc23a2

File tree

4 files changed

+41
-37
lines changed

4 files changed

+41
-37
lines changed

docs/userguide/development_mode.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ More information is available on the text of :pep:`PEP 660 <660#what-to-put-in-t
229229
used.
230230

231231

232+
Debugging Tips
233+
--------------
234+
235+
If encountering problems installing a project in editable mode,
236+
follow these recommended steps to help debug:
237+
238+
- Try to install the project normally, without using the editable mode.
239+
Does the error still persist?
240+
(If it does, try fixing the problem before attempting the editable mode).
241+
- When using binary extensions, make sure all OS-level
242+
dependencies are installed (e.g. compilers, toolchains, binary libraries, ...).
243+
- Try the latest version of setuptools (maybe the error was already fixed).
244+
- When the project or its dependencies are using any setuptools extension
245+
or customization, make sure they support the editable mode.
246+
247+
After following the steps above, if the problem still persists and
248+
you think this is related to how setuptools handles editable installations,
249+
please submit a `reproducible example <https://stackoverflow.com/help/minimal-reproducible-example>`_ at `the bug tracker <https://github.com/pypa/setuptools/issues>`_.
250+
232251
----
233252

234253
.. rubric:: Notes

setuptools/command/editable_wheel.py

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
from .. import Command, _normalization, _path, _shutil, errors, namespaces
3131
from .._path import StrPath
32-
from ..compat import py312
32+
from ..compat import py310, py312
3333
from ..discovery import find_package_path
3434
from ..dist import Distribution
35-
from ..warnings import InformationOnly, SetuptoolsDeprecationWarning, SetuptoolsWarning
35+
from ..warnings import InformationOnly, SetuptoolsDeprecationWarning
3636
from .build import build as build_cls
3737
from .build_py import build_py as build_py_cls
3838
from .dist_info import dist_info as dist_info_cls
@@ -137,13 +137,14 @@ def run(self) -> None:
137137
bdist_wheel.write_wheelfile(self.dist_info_dir)
138138

139139
self._create_wheel_file(bdist_wheel)
140-
except Exception:
140+
except Exception as ex:
141141
project = self.distribution.name or self.distribution.get_name()
142-
if os.environ.get('SETUPTOOLS_INTERNAL_DEBUG'):
143-
traceback.print_exc()
144-
_DebuggingTips.emit(project=project)
145-
else:
146-
print("An error occurred building editable wheel for", project)
142+
py310.add_note(
143+
ex,
144+
f"An error occurred when building editable wheel for {project}.\n"
145+
"See debugging tips in: "
146+
"https://setuptools.pypa.io/en/latest/userguide/development_mode.html#debugging-tips",
147+
)
147148
raise
148149

149150
def _ensure_dist_info(self):
@@ -905,29 +906,3 @@ def _finder_template(
905906

906907
class LinksNotSupported(errors.FileError):
907908
"""File system does not seem to support either symlinks or hard links."""
908-
909-
910-
class _DebuggingTips(SetuptoolsWarning):
911-
_SUMMARY = "Problem in editable installation."
912-
_DETAILS = """
913-
An error happened while installing `{project}` in editable mode.
914-
915-
The following steps are recommended to help debug this problem:
916-
917-
- Try to install the project normally, without using the editable mode.
918-
Does the error still persist?
919-
(If it does, try fixing the problem before attempting the editable mode).
920-
- If you are using binary extensions, make sure you have all OS-level
921-
dependencies installed (e.g. compilers, toolchains, binary libraries, ...).
922-
- Try the latest version of setuptools (maybe the error was already fixed).
923-
- If you (or your project dependencies) are using any setuptools extension
924-
or customization, make sure they support the editable mode.
925-
926-
After following the steps above, if the problem still persists and
927-
you think this is related to how setuptools handles editable installations,
928-
please submit a reproducible example
929-
(see https://stackoverflow.com/help/minimal-reproducible-example) to:
930-
931-
https://github.com/pypa/setuptools/issues
932-
"""
933-
_SEE_DOCS = "userguide/development_mode.html"

setuptools/compat/py310.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,14 @@
77
import tomllib
88
else: # pragma: no cover
99
import tomli as tomllib
10+
11+
12+
if sys.version_info >= (3, 11):
13+
14+
def add_note(ex, note):
15+
ex.add_note(note)
16+
17+
else: # pragma: no cover
18+
19+
def add_note(ex, note):
20+
vars(ex).setdefault('__notes__', []).append(note)

setuptools/tests/test_editable_install.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from setuptools._importlib import resources as importlib_resources
2323
from setuptools.command.editable_wheel import (
24-
_DebuggingTips,
2524
_encode_pth,
2625
_find_namespaces,
2726
_find_package_roots,
@@ -1201,9 +1200,9 @@ def test_debugging_tips(tmpdir_cwd, monkeypatch):
12011200
simulated_failure = Mock(side_effect=SimulatedErr())
12021201
monkeypatch.setattr(cmd, "get_finalized_command", simulated_failure)
12031202

1204-
expected_msg = "following steps are recommended to help debug"
1205-
with pytest.raises(SimulatedErr), pytest.warns(_DebuggingTips, match=expected_msg):
1203+
with pytest.raises(SimulatedErr) as ctx:
12061204
cmd.run()
1205+
assert any('debugging-tips' in note for note in ctx.value.__notes__)
12071206

12081207

12091208
@pytest.mark.filterwarnings("error")

0 commit comments

Comments
 (0)