Skip to content

Commit

Permalink
deps(python): drop Python 3.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Feb 16, 2023
1 parent f5b292c commit 35a786f
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 40 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7 - 3.10" # sync with requires-python in pyproject.toml
python-version: "3.8 - 3.11" # sync with requires-python in pyproject.toml
update-environment: true

- name: Set __release__
Expand Down Expand Up @@ -96,14 +96,14 @@ jobs:
run: |
make pytest
build-wheels-py37:
build-wheels-py38:
name: Build wheels for Python ${{ matrix.python-version }} on ubuntu-latest
runs-on: ubuntu-latest
needs: [build]
if: github.repository == 'metaopt/torchopt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
strategy:
matrix:
python-version: ["3.7"] # sync with requires-python in pyproject.toml
python-version: ["3.8"] # sync with requires-python in pyproject.toml
fail-fast: false
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -142,18 +142,18 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: wheels-py37
name: wheels-py38
path: wheelhouse/*.whl
if-no-files-found: error

build-wheels:
name: Build wheels for Python ${{ matrix.python-version }} on ubuntu-latest
runs-on: ubuntu-latest
needs: [build, build-wheels-py37]
needs: [build, build-wheels-py38]
if: github.repository == 'metaopt/torchopt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"] # sync with requires-python in pyproject.toml
python-version: ["3.9", "3.10"] # sync with requires-python in pyproject.toml
fail-fast: false
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:

publish:
runs-on: ubuntu-latest
needs: [build, build-wheels-py37, build-wheels]
needs: [build, build-wheels-py38, build-wheels]
if: |
github.repository == 'metaopt/torchopt' && github.event_name != 'pull_request' &&
(github.event_name != 'workflow_dispatch' || github.event.inputs.task == 'build-and-publish') &&
Expand All @@ -215,7 +215,7 @@ jobs:
uses: actions/setup-python@v4
if: startsWith(github.ref, 'refs/tags/')
with:
python-version: "3.7 - 3.11" # sync with requires-python in pyproject.toml
python-version: "3.8 - 3.11" # sync with requires-python in pyproject.toml
update-environment: true

- name: Set __release__
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: wheels-py37
name: wheels-py38
path: dist

- name: Download built wheels
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ jobs:
submodules: "recursive"
fetch-depth: 1

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.7" # the lowest version we support (sync with requires-python in pyproject.toml)
python-version: "3.8" # the lowest version we support (sync with requires-python in pyproject.toml)
update-environment: true

- name: Setup CUDA Toolkit
Expand Down Expand Up @@ -111,10 +111,10 @@ jobs:
submodules: "recursive"
fetch-depth: 1

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.7" # the lowest version we support (sync with requires-python in pyproject.toml)
python-version: "3.8" # the lowest version we support (sync with requires-python in pyproject.toml)
update-environment: true

- name: Upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus] # sync with requires-python
args: [--py38-plus] # sync with requires-python
stages: [commit, push, manual]
exclude: |
(?x)(
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ persistent=yes

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.7 # the lowest version we support (sync with requires-python in pyproject.toml)
py-version=3.8 # the lowest version we support (sync with requires-python in pyproject.toml)

# Discover python modules and packages in the file system subtree.
recursive=no
Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ pre-commit-install:

docs-install:
$(call check_pip_install_extra,pydocstyle,pydocstyle[toml])
$(call check_pip_install_extra,doc8,"doc8<1.0.0a0")
if ! $(PYTHON) -c "import sys; exit(sys.version_info < (3, 8))"; then \
$(PYTHON) -m pip uninstall --yes importlib-metadata; \
$(call check_pip_install_extra,importlib-metadata,"importlib-metadata<5.0.0a0"); \
fi
$(call check_pip_install,doc8)
$(call check_pip_install,sphinx)
$(call check_pip_install,sphinx-rtd-theme)
$(call check_pip_install,sphinx-autoapi)
Expand All @@ -75,7 +71,7 @@ docs-install:
$(call check_pip_install,sphinxcontrib-bibtex)
$(call check_pip_install,sphinx-autodoc-typehints)
$(call check_pip_install,myst-nb)
$(call check_pip_install_extra,sphinxcontrib.spelling,sphinxcontrib.spelling pyenchant)
$(call check_pip_install_extra,sphinxcontrib-spelling,sphinxcontrib-spelling pyenchant)

pytest-install:
$(call check_pip_install,pytest)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div align="center">

<a>![Python 3.7+](https://img.shields.io/badge/Python-3.7%2B-brightgreen.svg)</a>
<a>![Python 3.8+](https://img.shields.io/badge/Python-3.8%2B-brightgreen.svg)</a>
<a href="https://pypi.org/project/torchopt">![PyPI](https://img.shields.io/pypi/v/torchopt?logo=pypi)</a>
<a href="https://github.com/metaopt/torchopt/tree/HEAD/tests">![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/metaopt/torchopt/tests.yml?label=tests&logo=github)</a>
<a href="https://codecov.io/gh/metaopt/torchopt">![CodeCov](https://img.shields.io/codecov/c/gh/metaopt/torchopt)</a>
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies:
- mypy >= 0.990
- flake8
- flake8-bugbear
- doc8 < 1.0.0a0
- doc8
- pydocstyle
- clang-format >= 14
- clang-tools >= 14 # clang-tidy
Expand Down
4 changes: 2 additions & 2 deletions docs/source/developer/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ For example, the following command will build a wheel for Python 3.7:

.. code-block:: bash
CIBW_BUILD="cp37*manylinux*" python3 -m cibuildwheel --platform=linux --output-dir=wheelhouse --config-file=pyproject.toml
CIBW_BUILD="cp38*manylinux*" python3 -m cibuildwheel --platform=linux --output-dir=wheelhouse --config-file=pyproject.toml
You can change ``cp37*`` to ``cp310*`` to build for Python 3.10. See https://cibuildwheel.readthedocs.io/en/stable/options for more options.
You can change ``cp38*`` to ``cp310*`` to build for Python 3.10. See https://cibuildwheel.readthedocs.io/en/stable/options for more options.

.. |cibuildwheel| replace:: ``cibuildwheel``
.. _cibuildwheel: https://github.com/pypa/cibuildwheel
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "An efficient library for differentiable optimization for PyTorch.
readme = "README.md"
# Change this if wheels for `torch` is available
# Search "requires-python" and update all corresponding items
requires-python = ">= 3.7"
requires-python = ">= 3.8"
authors = [
{ name = "TorchOpt Contributors" },
{ name = "Jie Ren", email = "jieren9806@gmail.com" },
Expand All @@ -34,7 +34,6 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
# Sync with requires-python
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -74,7 +73,7 @@ lint = [
"mypy >= 0.990",
"flake8",
"flake8-bugbear",
"doc8 < 1.0.0a0", # unpin this when we drop support for Python 3.7
"doc8",
"pydocstyle[toml]",
"pyenchant",
"cpplint",
Expand Down Expand Up @@ -170,7 +169,7 @@ safe = true
line-length = 100
skip-string-normalization = true
# Sync with requires-python
target-version = ["py37", "py38", "py39", "py310", "py311"]
target-version = ["py38", "py39", "py310", "py311"]

[tool.isort]
atomic = true
Expand All @@ -184,7 +183,7 @@ multi_line_output = 3

[tool.mypy]
# Sync with requires-python
python_version = 3.7
python_version = 3.8
pretty = true
show_error_codes = true
show_error_context = true
Expand Down
3 changes: 1 addition & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pylint[spelling] >= 2.15.0
mypy >= 0.990
flake8
flake8-bugbear
# https://github.com/PyCQA/doc8/issues/112
doc8 < 1.0.0a0
doc8
pydocstyle[toml]
pyenchant
cpplint
Expand Down
3 changes: 1 addition & 2 deletions torchopt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@

import itertools
from abc import abstractmethod
from typing import TYPE_CHECKING, Callable, NamedTuple
from typing_extensions import Protocol # Python 3.8+
from typing import TYPE_CHECKING, Callable, NamedTuple, Protocol


if TYPE_CHECKING: # pragma: no cover
Expand Down
3 changes: 1 addition & 2 deletions torchopt/diff/zero_order/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from __future__ import annotations

import functools
from typing import Any, Callable, Sequence
from typing_extensions import Literal # Python 3.8+
from typing import Any, Callable, Literal, Sequence
from typing_extensions import TypeAlias # Python 3.10+

import torch
Expand Down
14 changes: 12 additions & 2 deletions torchopt/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@
"""Typing utilities."""

import abc
from typing import Callable, Dict, List, Optional, Sequence, Tuple, TypeVar, Union
from typing import (
Callable,
Dict,
List,
Optional,
Protocol,
Sequence,
Tuple,
TypeVar,
Union,
runtime_checkable,
)
from typing_extensions import TypeAlias # Python 3.10+
from typing_extensions import Protocol, runtime_checkable # Python 3.8+

import torch
import torch.distributed.rpc as rpc
Expand Down
3 changes: 1 addition & 2 deletions torchopt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import copy
import itertools
from typing import TYPE_CHECKING, NamedTuple, Sequence, cast, overload
from typing_extensions import Literal # Python 3.8+
from typing import TYPE_CHECKING, Literal, NamedTuple, Sequence, cast, overload
from typing_extensions import TypeAlias # Python 3.10+

import torch
Expand Down

0 comments on commit 35a786f

Please sign in to comment.