File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change
1
+ Added note about using the ``--pep-517 `` flag with ``pip `` to workaround
2
+ ``InvalidVersion `` errors for packages that are already installed in the system.
Original file line number Diff line number Diff line change @@ -2675,7 +2675,14 @@ def key(self):
2675
2675
@property
2676
2676
def parsed_version (self ):
2677
2677
if not hasattr (self , "_parsed_version" ):
2678
- self ._parsed_version = parse_version (self .version )
2678
+ try :
2679
+ self ._parsed_version = parse_version (self .version )
2680
+ except packaging .version .InvalidVersion as ex :
2681
+ info = f"(package: { self .project_name } )"
2682
+ if hasattr (ex , "add_note" ):
2683
+ ex .add_note (info ) # PEP 678
2684
+ raise
2685
+ raise packaging .version .InvalidVersion (f"{ str (ex )} { info } " ) from None
2679
2686
2680
2687
return self ._parsed_version
2681
2688
Original file line number Diff line number Diff line change @@ -77,7 +77,28 @@ def finalize_options(self):
77
77
# Honor setup.cfg's options.
78
78
dist .parse_config_files (ignore_option_errors = True )
79
79
if dist .setup_requires :
80
+ _fetch_build_eggs (dist )
81
+
82
+
83
+ def _fetch_build_eggs (dist ):
84
+ try :
80
85
dist .fetch_build_eggs (dist .setup_requires )
86
+ except Exception as ex :
87
+ msg = """
88
+ It is possible a package already installed in your system
89
+ contains an version that is invalid according to PEP 440.
90
+ You can try `pip install --use-pep517` as a workaround for this problem,
91
+ or rely on a new virtual environment.
92
+
93
+ If the problem refers to a package that is not installed yet,
94
+ please contact that package's maintainers or distributors.
95
+ """
96
+ if "InvalidVersion" in ex .__class__ .__name__ :
97
+ if hasattr (ex , "add_note" ):
98
+ ex .add_note (msg ) # PEP 678
99
+ else :
100
+ dist .announce (f"\n { msg } \n " )
101
+ raise
81
102
82
103
83
104
def setup (** attrs ):
You can’t perform that action at this time.
0 commit comments