diff options
author | Eli Schwartz <eschwartz93@gmail.com> | 2024-05-10 18:17:53 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-23 16:15:52 -0400 |
commit | 8fe8b1d829f057c556143a658d3f26bc66c69ee8 (patch) | |
tree | fba1f511571485fa8fe3f4fa00ebd35ffdb85398 | |
parent | eba5498e9b40fdc6fd7d9621a9262dbd8364ea62 (diff) | |
download | meson-8fe8b1d829f057c556143a658d3f26bc66c69ee8.zip meson-8fe8b1d829f057c556143a658d3f26bc66c69ee8.tar.gz meson-8fe8b1d829f057c556143a658d3f26bc66c69ee8.tar.bz2 |
minstall: fix symlink handling on python 3.13
We passed a wrapper hack for shutil.chown because some functionality
wasn't available in the stdlib. It was added in python 3.13 beta1, so
the tests fail when we actually test symlink handling.
Fixes failure to run test_install_subdir_symlinks_with_default_umask_and_mode
on python 3.13.
-rw-r--r-- | mesonbuild/minstall.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index a82be5e..36284f0 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -148,23 +148,29 @@ def set_chown(path: str, user: T.Union[str, int, None] = None, # be actually passed properly. # Not nice, but better than actually rewriting shutil.chown until # this python bug is fixed: https://bugs.python.org/issue18108 - real_os_chown = os.chown - def chown(path: T.Union[int, str, 'os.PathLike[str]', bytes, 'os.PathLike[bytes]'], - uid: int, gid: int, *, dir_fd: T.Optional[int] = dir_fd, - follow_symlinks: bool = follow_symlinks) -> None: - """Override the default behavior of os.chown + if sys.version_info >= (3, 13): + # pylint: disable=unexpected-keyword-arg + # cannot handle sys.version_info, https://github.com/pylint-dev/pylint/issues/9138 + shutil.chown(path, user, group, dir_fd=dir_fd, follow_symlinks=follow_symlinks) + else: + real_os_chown = os.chown - Use a real function rather than a lambda to help mypy out. Also real - functions are faster. - """ - real_os_chown(path, uid, gid, dir_fd=dir_fd, follow_symlinks=follow_symlinks) + def chown(path: T.Union[int, str, 'os.PathLike[str]', bytes, 'os.PathLike[bytes]'], + uid: int, gid: int, *, dir_fd: T.Optional[int] = dir_fd, + follow_symlinks: bool = follow_symlinks) -> None: + """Override the default behavior of os.chown - try: - os.chown = chown - shutil.chown(path, user, group) - finally: - os.chown = real_os_chown + Use a real function rather than a lambda to help mypy out. Also real + functions are faster. + """ + real_os_chown(path, uid, gid, dir_fd=dir_fd, follow_symlinks=follow_symlinks) + + try: + os.chown = chown + shutil.chown(path, user, group) + finally: + os.chown = real_os_chown def set_chmod(path: str, mode: int, dir_fd: T.Optional[int] = None, |