Skip to content

Commit d3b25a4

Browse files
authored
Feature/upgrade python version (#85)
* Small fixes. * Upgrade Python version according to SPEC 0. This fixes the minimum supported version to Python 3.10, according to SPEC 0 (https://scientific-python.org/specs/spec-0000/). It also adds Python 3.10, 3.11 and 3.12 to the CI test matrix. distutils was used for CRAN and is removed in Python 3.12. It is replaced by the third-party module packaging.
1 parent 0cdd4d3 commit d3b25a4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest, windows-latest]
12-
python-version: ['3.8', '3.9', '3.10']
12+
python-version: ['3.10', '3.11', '3.12']
1313
steps:
1414
- uses: actions/checkout@v3
1515
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ classifiers = [
2525
]
2626
dependencies = ["numpy", "scipy", "scikit-learn"]
2727
[project.optional-dependencies]
28-
cran = ["rdata"]
28+
cran = ["packaging", "rdata"]
2929
forex = ["forex_python>=1.6"]
3030
keel = ["pandas"]
3131
keras = ["tensorflow"]

skdatasets/repositories/cran.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import re
1212
import urllib
1313
import warnings
14-
from distutils.version import LooseVersion
1514
from html.parser import HTMLParser
1615
from pathlib import Path
1716
from typing import (
@@ -28,11 +27,11 @@
2827

2928
import numpy as np
3029
import pandas as pd
30+
import rdata
31+
from packaging.version import Version
3132
from sklearn.datasets import get_data_home
3233
from sklearn.utils import Bunch
3334

34-
import rdata
35-
3635
from .base import DatasetNotFoundError, fetch_tgz as _fetch_tgz
3736

3837
CRAN_URL: Final = "https://CRAN.R-project.org"
@@ -105,7 +104,7 @@ def _get_latest_version_offline(package_name: str) -> str | None:
105104

106105
if downloaded_packages:
107106
versions = [
108-
LooseVersion(p.name[(len(package_name) + 1) : -len(".tar.gz")])
107+
Version(p.name[(len(package_name) + 1):-len(".tar.gz")])
109108
for p in downloaded_packages
110109
]
111110

0 commit comments

Comments
 (0)