From d098706994e52510ebf5a4e96ca4ccf20d6a94b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Thu, 24 Nov 2022 04:55:13 +0000 Subject: [PATCH] MAINT: move cached_property backport to compat module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- mesonpy/__init__.py | 9 ++------- mesonpy/_compat.py | 8 ++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index f3c5ec807..c9b83d36d 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -49,7 +49,8 @@ import mesonpy._wheelfile from mesonpy._compat import ( - Collection, Iterator, Literal, Mapping, Path, typing_get_args + Collection, Iterator, Literal, Mapping, Path, cached_property, + typing_get_args ) @@ -57,12 +58,6 @@ import pyproject_metadata # noqa: F401 -if sys.version_info >= (3, 8): - from functools import cached_property -else: - cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731 - - __version__ = '0.11.0' diff --git a/mesonpy/_compat.py b/mesonpy/_compat.py index df341a51d..f410fea4d 100644 --- a/mesonpy/_compat.py +++ b/mesonpy/_compat.py @@ -2,6 +2,7 @@ # SPDX-FileCopyrightText: 2021 Quansight, LLC # SPDX-FileCopyrightText: 2021 Filipe Laíns +import functools import os import pathlib import sys @@ -25,6 +26,12 @@ from typing_extensions import get_args as typing_get_args +if sys.version_info >= (3, 8): + from functools import cached_property +else: + cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731 + + Path = Union[str, os.PathLike] @@ -38,6 +45,7 @@ def is_relative_to(path: pathlib.Path, other: Union[pathlib.Path, str]) -> bool: __all__ = [ + 'cached_property', 'is_relative_to', 'typing_get_args', 'Collection',