|
14 | 14 | import argparse |
15 | 15 | import collections |
16 | 16 | import contextlib |
| 17 | +import copy |
17 | 18 | import difflib |
18 | 19 | import functools |
19 | 20 | import importlib.machinery |
|
23 | 24 | import os |
24 | 25 | import pathlib |
25 | 26 | import platform |
| 27 | +import posixpath |
26 | 28 | import re |
27 | 29 | import shutil |
28 | 30 | import subprocess |
@@ -79,7 +81,7 @@ class InvalidLicenseExpression(Exception): # type: ignore[no-redef] |
79 | 81 | MesonArgs = Mapping[MesonArgsKeys, List[str]] |
80 | 82 |
|
81 | 83 |
|
82 | | -__version__ = '0.18.0.dev0' |
| 84 | +__version__ = '0.18.0' |
83 | 85 |
|
84 | 86 |
|
85 | 87 | _PYPROJECT_METADATA_VERSION = tuple(map(int, pyproject_metadata.__version__.split('.')[:2])) |
@@ -961,6 +963,33 @@ def sdist(self, directory: Path) -> pathlib.Path: |
961 | 963 |
|
962 | 964 | with tarfile.open(meson_dist_path, 'r:gz') as meson_dist, mesonpy._util.create_targz(sdist_path) as sdist: |
963 | 965 | for member in meson_dist.getmembers(): |
| 966 | + # Recursively resolve symbolic links. The source distribution |
| 967 | + # archive format specification allows for symbolic links as |
| 968 | + # long as the target path does not include a '..' component. |
| 969 | + # This makes symbolic links support unusable in most cases, |
| 970 | + # therefore include the symbolic link targets as regular files |
| 971 | + # in all cases. |
| 972 | + while member.issym(): |
| 973 | + name = member.name |
| 974 | + target = posixpath.normpath(posixpath.join(posixpath.dirname(member.name), member.linkname)) |
| 975 | + try: |
| 976 | + # This can be implemented using the .replace() method |
| 977 | + # in Python 3.12 and later. The .replace() method was |
| 978 | + # added as part of PEP 706 and back-ported to Python |
| 979 | + # 3.9 and later in patch releases, thus it cannot be |
| 980 | + # relied upon until the minimum supported Python |
| 981 | + # version is 3.12. |
| 982 | + member = copy.copy(meson_dist.getmember(target)) |
| 983 | + member.name = name |
| 984 | + except KeyError: |
| 985 | + warnings.warn( |
| 986 | + 'symbolic link with absolute path target, pointing outside the ' |
| 987 | + f'archive, or dangling ignored: {name}', stacklevel=1) |
| 988 | + break |
| 989 | + if member.isdir(): |
| 990 | + warnings.warn( |
| 991 | + f'symbolic link pointing to a directory ignored: {name}', stacklevel=1) |
| 992 | + |
964 | 993 | if member.isfile(): |
965 | 994 | file = meson_dist.extractfile(member.name) |
966 | 995 |
|
@@ -995,6 +1024,10 @@ def sdist(self, directory: Path) -> pathlib.Path: |
995 | 1024 |
|
996 | 1025 | sdist.addfile(member, file) |
997 | 1026 |
|
| 1027 | + elif not member.isdir() and not member.issym(): |
| 1028 | + warnings.warn( |
| 1029 | + f'special file in the source archive ignored: {member.name}', stacklevel=1) |
| 1030 | + |
998 | 1031 | # Add 'PKG-INFO'. |
999 | 1032 | member = tarfile.TarInfo(f'{dist_name}/PKG-INFO') |
1000 | 1033 | member.uid = member.gid = 0 |
|
0 commit comments