From f1817ea7b1005ff37d67645e2a37766779350466 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Mon, 19 Jan 2026 18:31:43 +0800 Subject: [PATCH] Add support to python 3.13 (#1486) --- .github/workflows/python-package.yml | 7 ++++++- README.md | 2 +- flaml/version.py | 2 +- setup.py | 12 ++++++------ test/automl/test_extra_models.py | 6 +++++- test/automl/test_multiclass.py | 6 +++++- test/spark/test_multiclass.py | 6 +++++- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 11258e54a..0659b4aa8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,7 +40,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -74,6 +74,11 @@ jobs: run: | pip install pyspark==4.0.1 pip list | grep "pyspark" + - name: On Ubuntu python 3.13, install pyspark 4.1.0 + if: matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' + run: | + pip install pyspark==4.1.0 + pip list | grep "pyspark" # # TODO: support ray # - name: If linux and python<3.11, install ray 2 # if: matrix.os == 'ubuntu-latest' && matrix.python-version < '3.11' diff --git a/README.md b/README.md index 18dc0b7f9..b4313980f 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ FLAML has a .NET implementation in [ML.NET](http://dot.net/ml), an open-source, ## Installation -The latest version of FLAML requires **Python >= 3.10 and < 3.13**. While other Python versions may work for core components, full model support is not guaranteed. FLAML can be installed via `pip`: +The latest version of FLAML requires **Python >= 3.10 and < 3.14**. While other Python versions may work for core components, full model support is not guaranteed. FLAML can be installed via `pip`: ```bash pip install flaml diff --git a/flaml/version.py b/flaml/version.py index 54499df34..60be088dc 100644 --- a/flaml/version.py +++ b/flaml/version.py @@ -1 +1 @@ -__version__ = "2.4.1" +__version__ = "2.4.2" diff --git a/setup.py b/setup.py index 0906b9fc0..3a0527075 100644 --- a/setup.py +++ b/setup.py @@ -52,8 +52,8 @@ setuptools.setup( ], "test": [ "numpy>=1.17,<2.0.0; python_version<'3.13'", - "numpy>2.0.0; python_version>='3.13'", - "jupyter; python_version<'3.13'", + "numpy>=1.17; python_version>='3.13'", + "jupyter", "lightgbm>=2.3.1", "xgboost>=0.90,<2.0.0; python_version<'3.11'", "xgboost>=2.0.0; python_version>='3.11'", @@ -68,10 +68,10 @@ setuptools.setup( "pre-commit", "torch", "torchvision", - "catboost>=0.26; python_version<'3.13'", + "catboost>=0.26", "rgf-python", "optuna>=2.8.0,<=3.6.1", - "openml; python_version<'3.13'", + "openml", "statsmodels>=0.12.2", "psutil", "dataclasses", @@ -82,7 +82,7 @@ setuptools.setup( "rouge_score", "hcrystalball", "seqeval", - "pytorch-forecasting; python_version<'3.13'", + "pytorch-forecasting", "mlflow-skinny<=2.22.1", # Refer to https://mvnrepository.com/artifact/org.mlflow/mlflow-spark "joblibspark>=0.5.0", "joblib<=1.3.2", @@ -140,7 +140,7 @@ setuptools.setup( "prophet>=1.1.5", "statsmodels>=0.12.2", "hcrystalball>=0.1.10", - "pytorch-forecasting>=0.10.4; python_version<'3.13'", + "pytorch-forecasting>=0.10.4", "pytorch-lightning>=1.9.0", "tensorboardX>=2.6", ], diff --git a/test/automl/test_extra_models.py b/test/automl/test_extra_models.py index 651737a41..b860a9abe 100644 --- a/test/automl/test_extra_models.py +++ b/test/automl/test_extra_models.py @@ -188,7 +188,11 @@ def _test_sparse_matrix_classification(estimator): "n_jobs": 1, "model_history": True, } - X_train = scipy.sparse.random(1554, 21, dtype=int) + # NOTE: Avoid `dtype=int` here. On some NumPy/SciPy combinations (notably + # Windows + Python 3.13), `scipy.sparse.random(..., dtype=int)` may trigger + # integer sampling paths which raise "low is out of bounds for int32". + # A float sparse matrix is sufficient to validate sparse-input support. + X_train = scipy.sparse.random(1554, 21, dtype=np.float32) y_train = np.random.randint(3, size=1554) automl_experiment.fit(X_train=X_train, y_train=y_train, **automl_settings) diff --git a/test/automl/test_multiclass.py b/test/automl/test_multiclass.py index 9be63cff6..012e019db 100644 --- a/test/automl/test_multiclass.py +++ b/test/automl/test_multiclass.py @@ -368,7 +368,11 @@ class TestMultiClass(unittest.TestCase): "n_jobs": 1, "model_history": True, } - X_train = scipy.sparse.random(1554, 21, dtype=int) + # NOTE: Avoid `dtype=int` here. On some NumPy/SciPy combinations (notably + # Windows + Python 3.13), `scipy.sparse.random(..., dtype=int)` may trigger + # integer sampling paths which raise "low is out of bounds for int32". + # A float sparse matrix is sufficient to validate sparse-input support. + X_train = scipy.sparse.random(1554, 21, dtype=np.float32) y_train = np.random.randint(3, size=1554) automl_experiment.fit(X_train=X_train, y_train=y_train, **automl_settings) print(automl_experiment.classes_) diff --git a/test/spark/test_multiclass.py b/test/spark/test_multiclass.py index 45f6e5b45..c9da98244 100644 --- a/test/spark/test_multiclass.py +++ b/test/spark/test_multiclass.py @@ -262,7 +262,11 @@ class TestMultiClass(unittest.TestCase): "n_concurrent_trials": 2, "use_spark": True, } - X_train = scipy.sparse.random(1554, 21, dtype=int) + # NOTE: Avoid `dtype=int` here. On some NumPy/SciPy combinations (notably + # Windows + Python 3.13), `scipy.sparse.random(..., dtype=int)` may trigger + # integer sampling paths which raise "low is out of bounds for int32". + # A float sparse matrix is sufficient to validate sparse-input support. + X_train = scipy.sparse.random(1554, 21, dtype=np.float32) y_train = np.random.randint(3, size=1554) automl_experiment.fit(X_train=X_train, y_train=y_train, **automl_settings) print(automl_experiment.classes_)