From 0538009d30c02aba7f3b0e2fb22589c55fbe0fd0 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 10 Dec 2017 19:05:15 +0200 Subject: [PATCH] Bump minimum supported Python from 3.4 to 3.5. --- .appveyor.yml | 2 +- mesonbuild/coredata.py | 4 ++-- mesonbuild/mesonlib.py | 25 ------------------------- mesonbuild/mesonmain.py | 4 ++-- run_unittests.py | 20 -------------------- 5 files changed, 5 insertions(+), 50 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2ef722f83..56a123a5b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -68,7 +68,7 @@ install: - ps: (new-object net.webclient).DownloadFile('http://nirbheek.in/files/binaries/ninja/win32/ninja.exe', 'C:\projects\meson\ninja.exe') # Use the x86 python only when building for x86 for the cpython tests. # For all other archs (including, say, arm), use the x64 python. - - cmd: if %arch%==x86 (set MESON_PYTHON_PATH=C:\python34) else (set MESON_PYTHON_PATH=C:\python34-x64) + - cmd: if %arch%==x86 (set MESON_PYTHON_PATH=C:\python35) else (set MESON_PYTHON_PATH=C:\python35-x64) # Set paths for BOOST dll files - cmd: if %compiler%==msvc2015 ( if %arch%==x86 ( set "PATH=%PATH%;C:\Libraries\boost_1_59_0\lib32-msvc-14.0" ) else ( set "PATH=%PATH%;C:\Libraries\boost_1_59_0\lib64-msvc-14.0" ) ) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index d4a91a7b0..0fdac8b8e 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -18,7 +18,7 @@ import pickle, os, uuid import sys from pathlib import PurePath from collections import OrderedDict -from .mesonlib import MesonException, commonpath +from .mesonlib import MesonException from .mesonlib import default_libdir, default_libexecdir, default_prefix import ast @@ -274,7 +274,7 @@ class CoreData: # commonpath will always return a path in the native format, so we # must use pathlib.PurePath to do the same conversion before # comparing. - if commonpath([value, prefix]) != str(PurePath(prefix)): + if os.path.commonpath([value, prefix]) != str(PurePath(prefix)): m = 'The value of the {!r} option is {!r} which must be a ' \ 'subdir of the prefix {!r}.\nNote that if you pass a ' \ 'relative path, it is assumed to be a subdir of prefix.' diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 66bf98edf..3b3299637 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -702,31 +702,6 @@ def Popen_safe_legacy(args, write=None, stderr=subprocess.PIPE, **kwargs): e = e.decode(errors='replace').replace('\r\n', '\n') return p, o, e -def commonpath(paths): - ''' - For use on Python 3.4 where os.path.commonpath is not available. - We currently use it everywhere so this receives enough testing. - ''' - # XXX: Replace me with os.path.commonpath when we start requiring Python 3.5 - import pathlib - if not paths: - raise ValueError('arg is an empty sequence') - common = pathlib.PurePath(paths[0]) - for path in paths[1:]: - new = [] - path = pathlib.PurePath(path) - for c, p in zip(common.parts, path.parts): - if c != p: - break - new.append(c) - # Don't convert '' into '.' - if not new: - common = '' - break - new = os.path.join(*new) - common = pathlib.PurePath(new) - return str(common) - def iter_regexin_iter(regexiter, initer): ''' Takes each regular expression in @regexiter and tries to search for it in diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 12bbd6914..e48122f92 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -279,8 +279,8 @@ def run_script_command(args): return cmdfunc(cmdargs) def run(original_args, mainfile=None): - if sys.version_info < (3, 4): - print('Meson works correctly only with python 3.4+.') + if sys.version_info < (3, 5): + print('Meson works correctly only with python 3.5+.') print('You have python %s.' % sys.version) print('Please update your environment') return 1 diff --git a/run_unittests.py b/run_unittests.py index dae72a849..08ad63209 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -191,26 +191,6 @@ class InternalTests(unittest.TestCase): l.append_direct('-lbar') self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-lbar']) - def test_commonpath(self): - from os.path import sep - commonpath = mesonbuild.mesonlib.commonpath - self.assertRaises(ValueError, commonpath, []) - self.assertEqual(commonpath(['/usr', '/usr']), sep + 'usr') - self.assertEqual(commonpath(['/usr', '/usr/']), sep + 'usr') - self.assertEqual(commonpath(['/usr', '/usr/bin']), sep + 'usr') - self.assertEqual(commonpath(['/usr/', '/usr/bin']), sep + 'usr') - self.assertEqual(commonpath(['/usr/./', '/usr/bin']), sep + 'usr') - self.assertEqual(commonpath(['/usr/bin', '/usr/bin']), sep + 'usr' + sep + 'bin') - self.assertEqual(commonpath(['/usr//bin', '/usr/bin']), sep + 'usr' + sep + 'bin') - self.assertEqual(commonpath(['/usr/./bin', '/usr/bin']), sep + 'usr' + sep + 'bin') - self.assertEqual(commonpath(['/usr/local', '/usr/lib']), sep + 'usr') - self.assertEqual(commonpath(['/usr', '/bin']), sep) - self.assertEqual(commonpath(['/usr', 'bin']), '') - self.assertEqual(commonpath(['blam', 'bin']), '') - prefix = '/some/path/to/prefix' - libdir = '/some/path/to/prefix/libdir' - self.assertEqual(commonpath([prefix, libdir]), str(PurePath(prefix))) - def test_string_templates_substitution(self): dictfunc = mesonbuild.mesonlib.get_filenames_templates_dict substfunc = mesonbuild.mesonlib.substitute_values