summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2023-01-20 11:12:08 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2023-01-20 11:12:08 +0000
commitf45c54a10438d0ae84d3908ee9d977273e7ad4fa (patch)
tree9f27884bc26b2b40d9592a0932da079b0a3cd4c0 /setuptools
parentcf9351dee7e8ec475468f83ecfb2e5f2de1b0ebe (diff)
parent7976b1525aadfa3b8111e048e966c685e07d6087 (diff)
downloadpython-setuptools-git-f45c54a10438d0ae84d3908ee9d977273e7ad4fa.tar.gz
Add informative notes for the InvalidVersion error (#3776)
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py
index 6c24cc2b..89f6f06e 100644
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -77,7 +77,28 @@ def _install_setup_requires(attrs):
# Honor setup.cfg's options.
dist.parse_config_files(ignore_option_errors=True)
if dist.setup_requires:
+ _fetch_build_eggs(dist)
+
+
+def _fetch_build_eggs(dist):
+ try:
dist.fetch_build_eggs(dist.setup_requires)
+ except Exception as ex:
+ msg = """
+ It is possible a package already installed in your system
+ contains an version that is invalid according to PEP 440.
+ You can try `pip install --use-pep517` as a workaround for this problem,
+ or rely on a new virtual environment.
+
+ If the problem refers to a package that is not installed yet,
+ please contact that package's maintainers or distributors.
+ """
+ if "InvalidVersion" in ex.__class__.__name__:
+ if hasattr(ex, "add_note"):
+ ex.add_note(msg) # PEP 678
+ else:
+ dist.announce(f"\n{msg}\n")
+ raise
def setup(**attrs):