Skip to content
Closed
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
13 changes: 7 additions & 6 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ def platform_tag(self) -> str:
platform_ = '-'.join(parts)
return platform_.replace('-', '_').replace('.', '_')

def _calculate_file_abi_tag_heuristic_windows(self, filename: str) -> Optional[mesonpy._tags.Tag]:
def _calculate_file_abi_tag_heuristic_windows(self, basename: str) -> Optional[mesonpy._tags.Tag]:
"""Try to calculate the Windows tag from the Python extension file name."""
match = _WINDOWS_NATIVE_MODULE_REGEX.match(filename)
match = _WINDOWS_NATIVE_MODULE_REGEX.match(basename)
if not match:
return None
tag = match.group('tag')
Expand All @@ -339,7 +339,7 @@ def _calculate_file_abi_tag_heuristic_windows(self, filename: str) -> Optional[m
except ValueError:
return mesonpy._tags.InterpreterTag(tag)

def _calculate_file_abi_tag_heuristic_posix(self, filename: str) -> Optional[mesonpy._tags.Tag]:
def _calculate_file_abi_tag_heuristic_posix(self, basename: str) -> Optional[mesonpy._tags.Tag]:
"""Try to calculate the Posix tag from the Python extension file name."""
# sysconfig is not guaranted to export SHLIB_SUFFIX but let's be
# preventive and check its value to make sure it matches our expectations
Expand All @@ -358,7 +358,7 @@ def _calculate_file_abi_tag_heuristic_posix(self, filename: str) -> Optional[mes
'Please report this to https://github.com/mesonbuild/mesonpy/issues '
'and include the output of `python -m sysconfig`.'
)
match = _LINUX_NATIVE_MODULE_REGEX.match(filename)
match = _LINUX_NATIVE_MODULE_REGEX.match(basename)
if not match: # this file does not appear to be a native module
return None
tag = match.group('tag')
Expand All @@ -370,10 +370,11 @@ def _calculate_file_abi_tag_heuristic_posix(self, filename: str) -> Optional[mes

def _calculate_file_abi_tag_heuristic(self, filename: str) -> Optional[mesonpy._tags.Tag]:
"""Try to calculate the ABI tag from the Python extension file name."""
basename = os.path.basename(filename)
if os.name == 'nt':
return self._calculate_file_abi_tag_heuristic_windows(filename)
return self._calculate_file_abi_tag_heuristic_windows(basename)
# everything else *should* follow the POSIX way, at least to my knowledge
return self._calculate_file_abi_tag_heuristic_posix(filename)
return self._calculate_file_abi_tag_heuristic_posix(basename)

def _file_list_repr(self, files: Collection[str], prefix: str = '\t\t', max_count: int = 3) -> str:
if len(files) > max_count:
Expand Down