diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-18 18:37:34 +0000 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-18 18:37:34 +0000 |
| commit | c6686252b025f4f07fad9e3fb152a073d4ac3f52 (patch) | |
| tree | b05adbff5da1f4b02616b353fe129ee3bed9d139 /setuptools | |
| parent | ca3198a52d48123d4d8e67952f1c9d5abba38d1f (diff) | |
| download | python-setuptools-git-c6686252b025f4f07fad9e3fb152a073d4ac3f52.tar.gz | |
Add informative notes for the InvalidVersion error (LegacyVersion removal)
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/__init__.py | 21 |
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): |
