diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2022-10-05 14:53:56 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-10-06 01:07:17 +0300 |
commit | b0eecda108708ce34ffcb97be7bc2b3ea64719de (patch) | |
tree | 8b215d890812ed955d31d674cf25885314f61281 /run_meson_command_tests.py | |
parent | df1b95cf2b015fc5b756609f2cae1e0dc7176702 (diff) | |
download | meson-b0eecda108708ce34ffcb97be7bc2b3ea64719de.zip meson-b0eecda108708ce34ffcb97be7bc2b3ea64719de.tar.gz meson-b0eecda108708ce34ffcb97be7bc2b3ea64719de.tar.bz2 |
Only use Debian path fixing on old distros.
Diffstat (limited to 'run_meson_command_tests.py')
-rwxr-xr-x | run_meson_command_tests.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py index 03083f0..a6a137b 100755 --- a/run_meson_command_tests.py +++ b/run_meson_command_tests.py @@ -19,29 +19,44 @@ import tempfile import unittest import subprocess import zipapp +import sysconfig from pathlib import Path from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows from mesonbuild.coredata import version as meson_version -# Handle the scheme that Debian patches in the as default -import sysconfig -# This function was renamed and made public in Python 3.10 -if hasattr(sysconfig, 'get_default_scheme'): - scheme = sysconfig.get_default_scheme() -else: - scheme = sysconfig._get_default_scheme() -if scheme == 'posix_local': - scheme = 'posix_prefix' +scheme = None + +def needs_debian_path_hack(): + try: + import setuptools + return int(setuptools.__version__.split('.')[0]) < 65 + except ModuleNotFoundError: + return False + +if needs_debian_path_hack(): + # Handle the scheme that Debian patches in the as default + # This function was renamed and made public in Python 3.10 + if hasattr(sysconfig, 'get_default_scheme'): + scheme = sysconfig.get_default_scheme() + else: + scheme = sysconfig._get_default_scheme() + if scheme == 'posix_local': + scheme = 'posix_prefix' def get_pypath(): - pypath = sysconfig.get_path('purelib', scheme=scheme, vars={'base': ''}) + if scheme: + pypath = sysconfig.get_path('purelib', scheme=scheme, vars={'base': ''}) + else: + pypath = sysconfig.get_path('purelib', vars={'base': ''}) # Ensure that / is the path separator and not \, then strip / return Path(pypath).as_posix().strip('/') def get_pybindir(): # 'Scripts' on Windows and 'bin' on other platforms including MSYS - return sysconfig.get_path('scripts', scheme=scheme, vars={'base': ''}).strip('\\/') + if scheme: + return sysconfig.get_path('scripts', scheme=scheme, vars={'base': ''}).strip('\\/') + return sysconfig.get_path('scripts', vars={'base': ''}).strip('\\/') class CommandTests(unittest.TestCase): ''' |