Skip to content

Commit f2ff7d1

Browse files
committed
Updated retrieval of max SciPy version
1 parent 90605ca commit f2ff7d1

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

versions.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,29 @@ def get_minor_versions_between(start_version_str, end_version_str):
230230
return versions
231231

232232

233+
def _get_scipy_pypi():
234+
url = "https://pypi.org/project/scipy/"
235+
req = request.Request(
236+
url,
237+
data=None,
238+
headers=HEADERS
239+
)
240+
return request.urlopen(req).read().decode("utf-8")
241+
242+
243+
def get_latest_scipy_version():
244+
html = _get_scipy_pypi()
245+
match = re.search(r'scipy\s+(\d+\.\d+\.\d+)', html, re.DOTALL)
246+
return match.groups()[0]
247+
248+
249+
def get_latest_scipy_python_version():
250+
html = _get_scipy_pypi()
251+
python_versions = list(set(re.findall(r'Python\s+\:\:\s+(\d+\.\d+)', html, re.DOTALL)))
252+
python_version = sorted(python_versions, key=Version)[-1]
253+
return f"<={python_version}"
254+
255+
233256
def get_latest_numpy_version():
234257
"""
235258
Retrieve the latest NumPy version
@@ -317,8 +340,8 @@ def get_all_max_versions():
317340
)
318341
)
319342
.assign(NUMPY=lambda row: row.apply(check_numpy_version, axis=1))
320-
.assign(SCIPY=get_scipy_version_df().iloc[0].SciPy_version)
321-
.assign(SCIPY_PYTHON_SPEC=get_scipy_version_df().iloc[0].Python_versions)
343+
.assign(SCIPY=get_latest_scipy_version())
344+
.assign(SCIPY_PYTHON_SPEC=get_latest_scipy_python_version())
322345
.pipe(
323346
lambda df: df.assign(
324347
SCIPY_PYTHON_SPEC=df.SCIPY_PYTHON_SPEC.apply(SpecifierSet)

0 commit comments

Comments
 (0)