Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(python): Officially support Python 3.13 #20549

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/benchmark-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:

- name: Clone Polars-benchmark
run: |
git clone --depth=1 https://github.com/pola-rs/polars-benchmark.git
git clone --depth=1 https://github.com/pola-rs/polars-benchmark.git

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'

- name: Create virtual environment
run: |
Expand All @@ -46,7 +46,7 @@ jobs:
# Install typing-extensions separately whilst the `--extra-index-url` in `requirements-ci.txt`
# doesn't have an up-to-date typing-extensions, see
# https://github.com/astral-sh/uv/issues/6028#issuecomment-2287232150
uv pip install -U typing-extensions
uv pip install -U typing-extensions
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose

- name: Install Polars-Benchmark dependencies
Expand All @@ -68,7 +68,7 @@ jobs:
working-directory: polars-benchmark
run: |
"$HOME/py-polars-cache/run-benchmarks.sh" | tee ../py-polars/benchmark-results

- name: Cache the Polars build
if: ${{ github.ref == 'refs/heads/main' }}
working-directory: py-polars
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'

- name: Set up Graphviz
uses: ts-graphviz/setup-graphviz@v2
Expand All @@ -52,8 +52,8 @@ jobs:
# Install typing-extensions separately whilst the `--extra-index-url` in `requirements-ci.txt`
# doesn't have an up-to-date typing-extensions, see
# https://github.com/astral-sh/uv/issues/6028#issuecomment-2287232150
uv pip install -U typing-extensions
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose
uv pip install -U typing-extensions
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose --index-strategy=unsafe-best-match
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --extra-index-url https://download.pytorch.org/whl/cpu entry in requirements-ci.txt caueses issues for NumPy installation under Python 3.13. Specifying this index strategy makes it so that NumPy is downloaded from the regular PyPI registry rather than the PyTorch registry.


- name: Set up Rust
run: rustup show
Expand Down Expand Up @@ -87,4 +87,4 @@ jobs:
working-directory: py-polars
env:
POLARS_AUTO_NEW_STREAMING: 1
run: pytest -n auto --dist loadgroup -m "not may_fail_auto_streaming and not slow and not write_disk and not release and not docs and not hypothesis and not benchmark and not ci_only"
run: pytest -n auto --dist loadgroup -m "not may_fail_auto_streaming and not slow and not write_disk and not release and not docs and not hypothesis and not benchmark and not ci_only"
2 changes: 1 addition & 1 deletion .github/workflows/docs-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.13'

- name: Create virtual environment
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.12']
python-version: ['3.9', '3.13']

steps:
- uses: actions/checkout@v4
Expand All @@ -58,7 +58,9 @@ jobs:

- name: Install Python dependencies
working-directory: py-polars
run: uv pip install -r requirements-dev.txt -r requirements-lint.txt
# TODO: Fix typing issues for newer NumPy versions
# https://github.com/pola-rs/polars/issues/20561
run: uv pip install -r requirements-dev.txt -r requirements-lint.txt 'numpy<2.1'

# Allow untyped calls for older Python versions
- name: Run mypy
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.9', '3.12']
python-version: ['3.9', '3.12', '3.13']
include:
- os: windows-latest
python-version: '3.12'
python-version: '3.13'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
# doesn't have an up-to-date typing-extensions, see
# https://github.com/astral-sh/uv/issues/6028#issuecomment-2287232150
uv pip install -U typing-extensions
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose --index-strategy=unsafe-best-match

- name: Set up Rust
run: rustup show
Expand All @@ -85,7 +85,7 @@ jobs:
run: maturin develop

- name: Run doctests
if: github.ref_name != 'main' && matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
if: github.ref_name != 'main' && matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest'
run: |
python tests/docs/run_doctest.py
pytest tests/docs/test_user_guide.py -m docs
Expand All @@ -107,7 +107,7 @@ jobs:
run: pytest -m "not release and not benchmark and not docs" tests/unit/io/

- name: Check import without optional dependencies
if: github.ref_name != 'main' && matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
if: github.ref_name != 'main' && matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest'
run: |
declare -a deps=("pandas"
"pyarrow"
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ rustup toolchain install nightly --component miri
```

Next, install Python, for example using [pyenv](https://github.com/pyenv/pyenv#installation). We
recommend using the latest Python version (`3.12`). Make sure you deactivate any active virtual
recommend using the latest Python version (`3.13`). Make sure you deactivate any active virtual
environments (command: `deactivate`) or conda environments (command: `conda deactivate`), as the
steps below will create a new [virtual environment](https://docs.python.org/3/tutorial/venv.html)
for Polars. You will need Python even if you intend to work on the Rust code only, as we rely on the
Expand Down
3 changes: 3 additions & 0 deletions py-polars/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Rust",
"Topic :: Scientific/Engineering",
]
Expand Down Expand Up @@ -258,6 +259,8 @@ filterwarnings = [
# Ignore invalid warnings when running earlier versions of SQLAlchemy (we
# know they are invalid because our standard tests run the latest version)
"ignore:Deprecated API features detected.*:DeprecationWarning",
# numpy import can generate this warning in Python 3.13 on certain runners
"ignore:.*numpy\\.longdouble.*:UserWarning",
]
xfail_strict = true

Expand Down
2 changes: 1 addition & 1 deletion py-polars/requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# (installable via `make requirements-all`)
# -------------------------------------------------------
--extra-index-url https://download.pytorch.org/whl/cpu
torch
torch; python_version < '3.13' or platform_system != 'Windows' # torch provides no wheel for Python 3.13 on Windows
jax[cpu]
pyiceberg>=0.5.0
9 changes: 8 additions & 1 deletion py-polars/tests/unit/ml/test_to_torch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
from typing import Any

import pytest
Expand All @@ -12,7 +13,13 @@
# ensures the tests aren't run locally; this avoids premature local import)
torch, _ = _lazy_import("torch")

pytestmark = pytest.mark.ci_only
pytestmark = [
pytest.mark.ci_only,
pytest.mark.skipif(
sys.platform == "win32" and sys.version_info >= (3, 13),
reason="Torch does not ship wheels for Python 3.13 on Windows",
),
]


@pytest.fixture
Expand Down
Loading