From 2fb36d1771df755a083bfdb40048889de1014cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BRIOL?= Date: Wed, 9 Oct 2024 23:24:57 +0200 Subject: [PATCH] Ensure the setup script is compatible with deprecated Python versions. --- .pre-commit-config.yaml | 1 + setup.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34b820d..e8831a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,7 @@ repos: hooks: - id: pyupgrade args: [--py310-plus] + exclude: setup.py - repo: https://github.com/PyCQA/flake8 rev: 7.1.0 hooks: diff --git a/setup.py b/setup.py index d28f9ea..4f97450 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ # All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. # Working directory -from typing import Any +from typing import Any, List, Optional, Tuple import os import pathlib import platform @@ -23,7 +23,7 @@ OSX_DEPLOYMENT_TARGET = '10.14' -def compare_setuptools_version(required: tuple[int, ...]) -> bool: +def compare_setuptools_version(required: Tuple[int, ...]) -> bool: """Compare the version of setuptools with the required version.""" current = tuple(map(int, setuptools.__version__.split('.')[:2])) return current >= required @@ -159,7 +159,7 @@ def run(self) -> None: self.build_cmake(ext) super().run() - def boost(self) -> list[str] | None: + def boost(self) -> Optional[List[str]]: """Return the Boost installation prefix.""" # Do not search system for Boost & disable the search for boost-cmake boost_option = '-DBoost_NO_SYSTEM_PATHS=TRUE ' \ @@ -176,7 +176,7 @@ def boost(self) -> list[str] | None: return None return f'{boost_option} -DBoost_INCLUDE_DIR={boost_root}'.split() - def eigen(self) -> str | None: + def eigen(self) -> Optional[str]: """Return the Eigen3 installation prefix.""" eigen_include_dir = pathlib.Path(sys.prefix, 'include', 'eigen3') if eigen_include_dir.exists(): @@ -217,7 +217,7 @@ def is_conda() -> bool: result = True return result - def set_cmake_user_options(self) -> list[str]: + def set_cmake_user_options(self) -> List[str]: """Set the CMake user options.""" cmake_variable: Any @@ -316,7 +316,7 @@ def build_cmake(self, ext) -> None: # pylint: enable=too-many-instance-attributes -def typehints() -> list[tuple[str, list[str]]]: +def typehints() -> List[Tuple[str, List[str]]]: """Get the list of type information files.""" pyi = [] for root, _, files in os.walk(WORKING_DIRECTORY):