File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -495,7 +495,13 @@ def pypi_source_urls(pkg_name):
495495 _log .debug ("Failed to download %s to determine available PyPI URLs for %s" , simple_url , pkg_name )
496496 res = []
497497 else :
498- parsed_html = ElementTree .parse (urls_html )
498+ urls_txt = read_file (urls_html )
499+
500+ # strip out data-yanked attributes before parsing HTML
501+ # see https://github.com/easybuilders/easybuild-framework/issues/3301
502+ urls_txt = re .sub ('\s*data-yanked' , '' , urls_txt )
503+
504+ parsed_html = ElementTree .ElementTree (ElementTree .fromstring (urls_txt ))
499505 if hasattr (parsed_html , 'iter' ):
500506 res = [a .attrib ['href' ] for a in parsed_html .iter ('a' )]
501507 else :
Original file line number Diff line number Diff line change @@ -1303,6 +1303,15 @@ def test_pypi_source_urls(self):
13031303 # more than 50 releases at time of writing test, which always stay there
13041304 self .assertTrue (len (res ) > 50 )
13051305
1306+ # check for Python package that has yanked releases,
1307+ # see https://github.com/easybuilders/easybuild-framework/issues/3301
1308+ res = ft .pypi_source_urls ('ipython' )
1309+ self .assertTrue (isinstance (res , list ) and res )
1310+ prefix = 'https://pypi.python.org/packages'
1311+ for entry in res :
1312+ self .assertTrue (entry .startswith (prefix ), "'%s' should start with '%s'" % (entry , prefix ))
1313+ self .assertTrue ('ipython' in entry , "Pattern 'ipython' should be found in '%s'" % entry )
1314+
13061315 def test_derive_alt_pypi_url (self ):
13071316 """Test derive_alt_pypi_url() function."""
13081317 url = 'https://pypi.python.org/packages/source/e/easybuild/easybuild-2.7.0.tar.gz'
You can’t perform that action at this time.
0 commit comments