Warning, file /graphics/krita/3rdparty/ext_python/_distutils_system_mod.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 # SPDX-FileCopyright: 2021 Alvin Wong <alvin@alvinhc.com> 0002 # SPDX-FileCopyright: 2022 L. E. Segovia <amy@amyspark.me> 0003 # SPDX-License-Ref: GPL-2.0-or-later 0004 0005 # Use the debian/pkgsrc hook to patch the MSVCRT lookup out. 0006 0007 from distutils import cygwinccompiler 0008 import sys 0009 0010 def _get_msvcr_replacement(): 0011 # So, the original `get_msvcr` function is supposed to return the name 0012 # of the specific version of MS C runtime so that it can be (?) copied 0013 # over. But we don't really need to do it since we have he packaging 0014 # script to take care of that. 0015 return [] 0016 0017 0018 if not callable(cygwinccompiler.get_msvcr): 0019 raise RuntimeError( 0020 "distutils.cygwinccompiler.get_msvcr is not a function, which is unexpected") 0021 0022 # print("[*] Krita is patching cygwinccompiler.get_msvcr... ({})".format(cygwinccompiler.__file__)) 0023 0024 # HACK: Replace the function to apply our hack... 0025 cygwinccompiler.get_msvcr = _get_msvcr_replacement 0026 0027 # print("[*] Check: {} {}".format(cygwinccompiler.get_msvcr, 0028 # cygwinccompiler.get_msvcr())) 0029 0030 0031 # distutils's cygwinccompiler module contains some very old version checking 0032 # code that had only been removed upstream recently in [1]. This includes a 0033 # version check for `ld`. The llvm-mingw toolchain only contains `ld.lld.exe` 0034 # as an executable but not `ld.exe`, which breaks this check. Here we just 0035 # monkey patch this check to return some modern version for `ld` to make the 0036 # check not fail. 0037 # [1]: https://github.com/pypa/distutils/commit/221a2f2888aa1a48887003c5afa10c1d18ae3a92 0038 0039 _original_get_versions = cygwinccompiler.get_versions 0040 0041 def _get_versions_replacement(): 0042 gcc_ver, ld_ver, dllwrap_ver = _original_get_versions() 0043 if ld_ver is None: 0044 ld_ver = "2.37" 0045 return gcc_ver, ld_ver, dllwrap_ver 0046 0047 if callable(cygwinccompiler.get_versions): 0048 # print("[*] Krita is patching cygwinccompiler.get_versions... ({})".format(cygwinccompiler.__file__)) 0049 cygwinccompiler.get_versions = _get_versions_replacement 0050 0051 0052 # HACK: Override distutils.cygwinccompiler lookup 0053 # https://github.com/pypa/setuptools/blob/298f5a6368397977ee09cb0b39d5f76aa544b048/setuptools/_distutils/ccompiler.py#L1024 0054 # print("[*] Freezing distutils.cygwinccompiler module") 0055 0056 sys.modules["distutils.cygwinccompiler"] = cygwinccompiler