Bump to python3.10 + update linter (#3809)

* py310 and some changes

* fix

* better
This commit is contained in:
Marc Sun
2025-10-10 18:22:51 +02:00
committed by GitHub
parent bc2478a472
commit df0c1870d9
11 changed files with 22 additions and 26 deletions

View File

@ -27,10 +27,10 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up python 3.9
- name: Set up python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'

View File

@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install Python dependencies

View File

@ -21,7 +21,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'

View File

@ -39,10 +39,10 @@ jobs:
]
steps:
- uses: actions/checkout@v4
- name: Set up python 3.9
- name: Set up python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'

View File

@ -27,10 +27,10 @@ jobs:
]
steps:
- uses: actions/checkout@v4
- name: Set up python 3.9
- name: Set up python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'

View File

@ -8,19 +8,16 @@ extra_quality_checks:
python utils/check_copies.py
python utils/check_dummies.py
python utils/check_repo.py
doc-builder style src/accelerate docs/source --max_len 119
# this target runs checks on all files
quality:
ruff check $(check_dirs)
ruff format --check $(check_dirs)
doc-builder style src/accelerate docs/source --max_len 119 --check_only
# Format source code automatically and check is there are any problems left that need manual fixing
style:
ruff check $(check_dirs) --fix
ruff format $(check_dirs)
doc-builder style src/accelerate docs/source --max_len 119
# Run tests for the library
test_core:

View File

@ -1,7 +1,7 @@
# Builds CPU-only Docker image of PyTorch
# Uses multi-staged approach to reduce size
# Stage 1
FROM python:3.9-slim as compile-image
FROM python:3.10-slim as compile-image
ARG DEBIAN_FRONTEND=noninteractive
@ -25,7 +25,7 @@ RUN python3 -m pip install --no-cache-dir \
--extra-index-url https://download.pytorch.org/whl/cpu
# Stage 2
FROM python:3.9-slim AS build-image
FROM python:3.10-slim AS build-image
COPY --from=compile-image /opt/venv /opt/venv
RUN useradd -ms /bin/bash user
USER user

View File

@ -4,7 +4,6 @@
# Use base conda image to reduce time
FROM continuumio/miniconda3:latest AS compile-image
# Specify py version
# Note: DeepSpeed beyond v0.12.6 requires py 3.10
ENV PYTHON_VERSION=3.10
# Install apt libs
RUN apt-get update && \

View File

@ -4,7 +4,7 @@
# Use base conda image to reduce time
FROM continuumio/miniconda3:latest AS compile-image
# Specify py version
ENV PYTHON_VERSION=3.9
ENV PYTHON_VERSION=3.10
# Install apt libs
RUN apt-get update && \
apt-get install -y curl git wget && \

View File

@ -1,6 +1,6 @@
[tool.ruff]
line-length = 119
target-version = "py39"
target-version = "py310"
[tool.ruff.lint]
preview = true
@ -20,6 +20,9 @@ ignore = [
"E741", # Ambiguous variable name
"W605", # Invalid escape sequence
"UP007", # X | Y type annotations
"UP045", # Use `X | None` for type annotations
"UP035", # temporarily disabled to minimize upgrade changes
]
[tool.ruff.lint.per-file-ignores]

View File

@ -16,13 +16,10 @@ from setuptools import find_packages, setup
extras = {}
extras["quality"] = [
"black ~= 23.1", # hf-doc-builder has a hidden dependency on `black`
"hf-doc-builder >= 0.3.0",
"ruff ~= 0.11.2",
]
extras["quality"] = ["ruff == 0.13.1"]
extras["docs"] = []
extras["test_prod"] = ["pytest>=7.2.0,<=8.0.0", "pytest-xdist", "pytest-subtests", "parameterized", "pytest-order"]
extras["test_prod"] = ["pytest>=7.2.0", "pytest-xdist", "pytest-subtests", "parameterized", "pytest-order"]
extras["test_dev"] = [
"datasets",
"diffusers",
@ -79,9 +76,9 @@ setup(
"accelerate-merge-weights=accelerate.commands.merge:main",
]
},
python_requires=">=3.9.0",
python_requires=">=3.10.0",
install_requires=[
"numpy>=1.17,<3.0.0",
"numpy>=1.17",
"packaging>=20.0",
"psutil",
"pyyaml",
@ -98,7 +95,7 @@ setup(
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
)