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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ jobs:
run: python -m pip install .

- name: Install mypy
run: python -m pip install mypy==1.5.1
run: python -m pip install mypy~=1.19

- name: Run mypy
run: mypy -p mesonpy
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ py = import('python').find_installation()

py.install_sources(
'mesonpy/__init__.py',
'mesonpy/_compat.py',
'mesonpy/_editable.py',
'mesonpy/_rpath.py',
'mesonpy/_tags.py',
Expand Down
15 changes: 8 additions & 7 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import fnmatch
import functools
import importlib.machinery
import importlib.resources
import io
import itertools
import json
Expand Down Expand Up @@ -55,8 +56,6 @@
import mesonpy._util
import mesonpy._wheelfile

from mesonpy._compat import read_binary


try:
from packaging.licenses import InvalidLicenseExpression, canonicalize_license_expression
Expand All @@ -73,15 +72,17 @@ class InvalidLicenseExpression(Exception): # type: ignore[no-redef]


if typing.TYPE_CHECKING: # pragma: no cover
from collections.abc import Collection, Iterator, Mapping
from typing import Any, Callable, DefaultDict, Dict, List, Literal, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union

from mesonpy._compat import Collection, Iterator, Mapping, ParamSpec, Path, Self
from typing_extensions import ParamSpec, Self

P = ParamSpec('P')
T = TypeVar('T')

MesonArgsKeys = Literal['dist', 'setup', 'compile', 'install']
MesonArgs = Mapping[MesonArgsKeys, List[str]]
Path = Union[str, os.PathLike[str]]


__version__ = '0.21.0.dev0'
Expand Down Expand Up @@ -207,7 +208,7 @@ def _use_ansi_escapes() -> bool:
# names containing characters that cannot be represented in the
# stdout encoding. Use replacement markers for those instead than
# raising UnicodeEncodeError.
sys.stdout.reconfigure(errors='replace') # type: ignore[attr-defined]
sys.stdout.reconfigure(errors='replace') # type: ignore[union-attr]

if 'NO_COLOR' in os.environ:
return False
Expand Down Expand Up @@ -552,7 +553,7 @@ def build(self, directory: Path, source_dir: pathlib.Path, build_dir: pathlib.Pa
loader_module_name = f'_{self._metadata.distribution_name}_editable_loader'
whl.writestr(
f'{loader_module_name}.py',
read_binary('mesonpy', '_editable.py') + textwrap.dedent(f'''
importlib.resources.files('mesonpy').joinpath('_editable.py').read_bytes() + textwrap.dedent(f'''
install(
{self._metadata.name!r},
{self._top_level_modules!r},
Expand Down Expand Up @@ -598,7 +599,7 @@ def _string_or_path(value: Any, name: str) -> str:
if not isinstance(value, str):
raise ConfigError(f'Configuration entry "{name}" must be a string')
if os.path.isfile(value):
value = os.path.abspath(value)
return os.path.abspath(value)
return value

scheme = _table({
Expand Down Expand Up @@ -1033,7 +1034,7 @@ def sdist(self, directory: Path) -> pathlib.Path:
meson_dist_name = f'{self._meson_name}-{meson_version}'
meson_dist_path = pathlib.Path(self._build_dir, 'meson-dist', f'{meson_dist_name}.tar.gz')
sdist_path = pathlib.Path(directory, f'{dist_name}.tar.gz')
pyproject_toml_mtime = 0
pyproject_toml_mtime: Union[int, float] = 0

with tarfile.open(meson_dist_path, 'r:gz') as meson_dist, mesonpy._util.create_targz(sdist_path) as sdist:
for member in meson_dist.getmembers():
Expand Down
54 changes: 0 additions & 54 deletions mesonpy/_compat.py

This file was deleted.

15 changes: 5 additions & 10 deletions mesonpy/_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@

if sys.version_info >= (3, 12):
from importlib.resources.abc import Traversable, TraversableResources
elif sys.version_info >= (3, 9):
from importlib.abc import Traversable, TraversableResources
else:
class Traversable:
pass
class TraversableResources:
pass
from importlib.abc import Traversable, TraversableResources


MARKER = 'MESONPY_EDITABLE_SKIP'
Expand Down Expand Up @@ -101,7 +96,7 @@ def is_file(self) -> bool:

def iterdir(self) -> Iterator[Traversable]:
for name, node in self._tree.items():
yield MesonpyTraversable(name, node) if isinstance(node, dict) else pathlib.Path(node) # type: ignore
yield MesonpyTraversable(name, node) if isinstance(node, dict) else pathlib.Path(node)

def open(self, *args, **kwargs): # type: ignore
raise IsADirectoryError()
Expand Down Expand Up @@ -147,7 +142,7 @@ def __init__(self, name: str, path: str, tree: Node):
super().__init__(name, path)
self._tree = tree

def get_resource_reader(self, name: str) -> TraversableResources:
def get_resource_reader(self, name: str) -> TraversableResources: # type: ignore[override]
return MesonpyReader(name, self._tree)


Expand All @@ -160,7 +155,7 @@ def set_data(self, path: Union[bytes, str], data: Buffer, *, _mode: int = ...) -
# disable saving bytecode
pass

def get_resource_reader(self, name: str) -> TraversableResources:
def get_resource_reader(self, name: str) -> TraversableResources: # type: ignore[override]
return MesonpyReader(name, self._tree)


Expand All @@ -169,7 +164,7 @@ def __init__(self, name: str, path: str, tree: Node):
super().__init__(name, path)
self._tree = tree

def get_resource_reader(self, name: str) -> TraversableResources:
def get_resource_reader(self, name: str) -> TraversableResources: # type: ignore[override]
return MesonpyReader(name, self._tree)


Expand Down
5 changes: 2 additions & 3 deletions mesonpy/_rpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@


if typing.TYPE_CHECKING:
from typing import List

from mesonpy._compat import Iterable, Path
from typing import Iterable, List, Union
Path = Union[str, os.PathLike[str]]


if sys.platform == 'win32' or sys.platform == 'cygwin':
Expand Down
3 changes: 2 additions & 1 deletion mesonpy/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@


if typing.TYPE_CHECKING: # pragma: no cover
from mesonpy._compat import Iterator, Path
from typing import Iterator, Union
Path = Union[str, os.PathLike[str]]


@contextlib.contextmanager
Expand Down
3 changes: 1 addition & 2 deletions mesonpy/_wheelfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
if typing.TYPE_CHECKING: # pragma: no cover
from types import TracebackType
from typing import List, Optional, Tuple, Type, Union

from mesonpy._compat import Path
Path = Union[str, os.PathLike[str]]


MIN_TIMESTAMP = 315532800 # 1980-01-01 00:00:00 UTC
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ test = [
'pytest-mock',
'cython >= 3.0.3', # required for Python 3.12 support
'wheel',
'typing-extensions >= 3.7.4; python_version < "3.11"',
]
docs = [
'furo >= 2024.08.06',
Expand Down
1 change: 0 additions & 1 deletion tests/test_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def test_resources(tmp_path):
assert text == 'ABC'


@pytest.mark.skipif(sys.version_info < (3, 9), reason='importlib.resources not available')
def test_importlib_resources(tmp_path):
# build a package in a temporary directory
package_path = pathlib.Path(__file__).parent / 'packages' / 'simple'
Expand Down
1 change: 0 additions & 1 deletion tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def test_tag_stable_abi():
assert str(builder.tag) == f'{INTERPRETER}-{abi}-{PLATFORM}'


@pytest.mark.xfail(sys.version_info < (3, 8) and sys.platform == 'win32', reason='Extension modules suffix without ABI tags')
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not support the stable ABI')
def test_tag_mixed_abi():
builder = wheel_builder_test_factory({
Expand Down
Loading