diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index fd8f6ebc..3281bb1d 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -175,7 +175,7 @@ def _map_to_wheel( relpath = os.path.relpath(dirsrc, src) if relpath in exclude_dirs: dirnames.remove(name) - # sort to process directories determninistically + # sort to process directories deterministically dirnames.sort() for name in sorted(filenames): filesrc = os.path.join(root, name) @@ -202,7 +202,7 @@ def strip(string: str) -> str: return re.sub(r'\033\[[;?0-9]*[a-zA-Z]', '', string) -@functools.lru_cache() +@functools.cache def _use_ansi_escapes() -> bool: """Determine whether logging should use ANSI escapes.""" @@ -223,7 +223,7 @@ def _use_ansi_escapes() -> bool: return False -def _log(string: str , **kwargs: Any) -> None: +def _log(string: str, **kwargs: Any) -> None: if not _use_ansi_escapes(): string = style.strip(string) print(string, **kwargs) @@ -462,7 +462,7 @@ def _install_path(self, wheel_file: mesonpy._wheelfile.WheelFile, origin: Path, 'setting the DLL load path or preloading. See the documentation for ' 'the "tool.meson-python.allow-windows-internal-shared-libs" option.') - # When an executable, libray, or Python extension module is + # When an executable, library, or Python extension module is # dynamically linked to a library built as part of the project, # Meson adds a library load path to it pointing to the build # directory, in the form of a relative RPATH entry. meson-python @@ -639,7 +639,7 @@ def _empty_or_bool(value: Any, name: str) -> bool: raise ConfigError(f'Invalid value for "{name}": {value!r}') def _string_or_strings(value: Any, name: str) -> List[str]: - return list([value,] if isinstance(value, str) else value) + return [value] if isinstance(value, str) else list(value) options = { 'builddir': _string, @@ -955,12 +955,12 @@ def _build_command(self) -> List[str]: return cmd return [self._ninja, *self._meson_args['compile']] - @functools.lru_cache(maxsize=None) + @functools.cache def build(self) -> None: """Build the Meson project.""" self._run(self._build_command) - @functools.lru_cache() + @functools.cache def _info(self, name: str) -> Any: """Read info from meson-info directory.""" info = self._build_dir.joinpath('meson-info', f'{name}.json') @@ -1209,7 +1209,7 @@ def _get_meson_command( # The meson Python package is a dependency of the meson-python Python # package, however, it may occur that the meson Python package is installed # but the corresponding meson command is not available in $PATH. Implement - # a runtime check to verify that the build environment is setup correcly. + # a runtime check to verify that the build environment is setup correctly. try: r = subprocess.run(cmd + ['--version'], text=True, capture_output=True) except FileNotFoundError as err: diff --git a/mesonpy/_editable.py b/mesonpy/_editable.py index 3dd9d2a7..7568d069 100644 --- a/mesonpy/_editable.py +++ b/mesonpy/_editable.py @@ -225,7 +225,7 @@ def walk(src: str, exclude_files: Set[str], exclude_dirs: Set[str]) -> Iterator[ relpath = os.path.relpath(dirsrc, src) if relpath in exclude_dirs: dirnames.remove(name) - # sort to process directories determninistically + # sort to process directories deterministically dirnames.sort() for name in sorted(filenames): filesrc = os.path.join(root, name) diff --git a/mesonpy/_tags.py b/mesonpy/_tags.py index 9c09fe5a..9bb93bad 100644 --- a/mesonpy/_tags.py +++ b/mesonpy/_tags.py @@ -43,16 +43,6 @@ def _get_config_var(name: str, default: Union[str, int, None] = None) -> Union[s return value -def _get_cpython_abi() -> str: - version = sys.version_info - debug = pymalloc = '' - if _get_config_var('Py_DEBUG', hasattr(sys, 'gettotalrefcount')): - debug = 'd' - if version < (3, 8) and _get_config_var('WITH_PYMALLOC', True): - pymalloc = 'm' - return f'cp{version[0]}{version[1]}{debug}{pymalloc}' - - def get_abi_tag() -> str: # The best solution to obtain the Python ABI is to parse the # $SOABI or $EXT_SUFFIX sysconfig variables as defined in PEP-314. @@ -61,16 +51,7 @@ def get_abi_tag() -> str: # Using $EXT_SUFFIX will not break when PyPy will fix this. # See https://foss.heptapod.net/pypy/pypy/-/issues/3816 and # https://github.com/pypa/packaging/pull/607. - try: - empty, abi, ext = str(sysconfig.get_config_var('EXT_SUFFIX')).split('.') - except ValueError as exc: - # CPython <= 3.8.7 on Windows does not implement PEP3149 and - # uses '.pyd' as $EXT_SUFFIX, which does not allow to extract - # the interpreter ABI. Check that the fallback is not hit for - # any other Python implementation. - if sys.implementation.name != 'cpython': - raise NotImplementedError from exc - return _get_cpython_abi() + empty, abi, ext = str(sysconfig.get_config_var('EXT_SUFFIX')).split('.') # The packaging module initially based his understanding of the # $SOABI variable on the inconsistent value reported by PyPy, and @@ -115,7 +96,7 @@ def _get_macosx_platform_tag() -> str: version = tuple(map(int, ver.split('.')))[:2] # Python built with older macOS SDK on macOS 11, reports an - # unexising macOS 10.16 version instead of the real version. + # nonexistent macOS 10.16 version instead of the real version. # # The packaging module introduced a workaround # https://github.com/pypa/packaging/commit/67c4a2820c549070bbfc4bfbf5e2a250075048da @@ -144,7 +125,7 @@ def _get_macosx_platform_tag() -> str: major, minor = version if major >= 11: - # For macOS reelases up to 10.15, the major version number is + # For macOS releases up to 10.15, the major version number is # actually part of the OS name and the minor version is the # actual OS release. Starting with macOS 11, the major # version number is the OS release and the minor version is @@ -172,7 +153,7 @@ def _get_ios_platform_tag() -> str: # Although _multiarch is an internal implementation detail, it's a core part # of how CPython is implemented on iOS; this attribute is also relied upon - # by `packaging` as part of tag determiniation. + # by `packaging` as part of tag determination. multiarch = sys.implementation._multiarch.replace('-', '_') return f'ios_{version[0]}_{version[1]}_{multiarch}' diff --git a/mesonpy/_util.py b/mesonpy/_util.py index e2052b92..beda5d1e 100644 --- a/mesonpy/_util.py +++ b/mesonpy/_util.py @@ -33,7 +33,7 @@ def chdir(path: Path) -> Iterator[Path]: @contextlib.contextmanager def create_targz(path: Path) -> Iterator[tarfile.TarFile]: - """Opens a .tar.gz file in the file system for edition..""" + """Opens a .tar.gz file in the file system for edition.""" os.makedirs(os.path.dirname(path), exist_ok=True) file = typing.cast(IO[bytes], gzip.GzipFile(