@@ -230,44 +230,48 @@ def get_minor_versions_between(start_version_str, end_version_str):
230230 return versions
231231
232232
233- def _get_scipy_pypi ():
234- """
235- Retrieve the SciPy PyPI JSON file
236- """
237- url = "https://pypi.org/project/scipy/"
238- req = request .Request (url , data = None , headers = HEADERS )
239- return request .urlopen (req ).read ().decode ("utf-8" )
240-
241-
242233def get_latest_scipy_version ():
243234 """
244- Retrieve the latest SciPy Version
235+ Reteive the latest SciPy version
245236 """
246- html = _get_scipy_pypi ()
247- match = re .search (r"scipy\s+(\d+\.\d+\.\d+)" , html , re .DOTALL )
248- return match .groups ()[0 ]
237+ print (_get_all_pkg_versions ("scipy" )[- 1 ])
238+ return _get_all_pkg_versions ("scipy" )[- 1 ]
249239
250240
251241def get_latest_scipy_python_version ():
252242 """
253243 Retrieve the latest Python version that is supported by SciPy
254244 """
255- html = _get_scipy_pypi ()
256- python_versions = list (
257- set (re .findall (r"Python\s+\:\:\s+(\d+\.\d+)" , html , re .DOTALL ))
258- )
245+ python_versions = []
246+ response = _get_pypi_json ("scipy" )
247+ for classifier in response .get ("info" ).get ("classifiers" ):
248+ if "Python" in classifier :
249+ match = re .search (r"Python\s+\:\:\s+(\d+\.\d+)" , classifier )
250+ if match is not None :
251+ python_versions .append (match .groups ()[0 ])
259252 python_version = sorted (python_versions , key = Version )[- 1 ]
260253 return f"<={ python_version } "
261254
262255
263- def get_latest_numpy_version ():
256+ def _get_pypi_json (pkg ):
257+ url = f"https://pypi.python.org/pypi/{ pkg } /json"
258+ response = json .loads (request .urlopen (url ).read ())
259+ return response
260+
261+
262+ def _get_all_pkg_versions (pkg ):
263+ response = _get_pypi_json (pkg )
264+ all_versions = response ["releases" ]
265+ all_versions = [version for version in all_versions .keys () if "rc" not in version ]
266+ all_versions = sorted (all_versions , key = Version )
267+ return all_versions
268+
269+
270+ def get_latest_numpy_versions (n = 10 ):
264271 """
265- Retrieve the latest NumPy version
272+ Retrieve the n latest NumPy versions
266273 """
267- url = "https://pypi.python.org/pypi/numpy/json"
268- releases = json .loads (request .urlopen (url ).read ())["releases" ]
269- releases = [version for version in releases .keys () if "rc" not in version ]
270- return releases [- 1 ]
274+ return _get_all_pkg_versions ("numpy" )[- n :]
271275
272276
273277def check_python_version (row ):
@@ -289,10 +293,11 @@ def check_numpy_version(row):
289293 """
290294 Ensure that the NumPy version is compatible with the NumPy Specs
291295 """
292- if row .NUMPY in row .NUMPY_SPEC :
293- return row .NUMPY
294- else :
295- return None
296+ out = None
297+ for numpy_version in row .NUMPY :
298+ if numpy_version in row .NUMPY_SPEC :
299+ out = numpy_version
300+ return out
296301
297302
298303def get_all_max_versions ():
@@ -334,7 +339,11 @@ def get_all_max_versions():
334339 ).apply (SpecifierSet )
335340 )
336341 )
337- .assign (NUMPY = get_latest_numpy_version ())
342+ .pipe (
343+ lambda df : df .assign (
344+ NUMPY = ([get_latest_numpy_versions () for i in df .index ])
345+ )
346+ )
338347 .pipe (
339348 lambda df : df .assign (
340349 NUMPY_SPEC = (
0 commit comments