Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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."""

Expand All @@ -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:
Comment thread
rgommers marked this conversation as resolved.
if not _use_ansi_escapes():
string = style.strip(string)
print(string, **kwargs)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mesonpy/_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 4 additions & 23 deletions mesonpy/_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}'
Expand Down
2 changes: 1 addition & 1 deletion mesonpy/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading