Bump minimum supported Python from 3.4 to 3.5.

pull/2877/head
Jussi Pakkanen 7 years ago
parent 65f78a722a
commit 0538009d30
  1. 2
      .appveyor.yml
  2. 4
      mesonbuild/coredata.py
  3. 25
      mesonbuild/mesonlib.py
  4. 4
      mesonbuild/mesonmain.py
  5. 20
      run_unittests.py

@ -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') - 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. # Use the x86 python only when building for x86 for the cpython tests.
# For all other archs (including, say, arm), use the x64 python. # 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 # 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" ) ) - 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" ) )

@ -18,7 +18,7 @@ import pickle, os, uuid
import sys import sys
from pathlib import PurePath from pathlib import PurePath
from collections import OrderedDict from collections import OrderedDict
from .mesonlib import MesonException, commonpath from .mesonlib import MesonException
from .mesonlib import default_libdir, default_libexecdir, default_prefix from .mesonlib import default_libdir, default_libexecdir, default_prefix
import ast import ast
@ -274,7 +274,7 @@ class CoreData:
# commonpath will always return a path in the native format, so we # commonpath will always return a path in the native format, so we
# must use pathlib.PurePath to do the same conversion before # must use pathlib.PurePath to do the same conversion before
# comparing. # 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 ' \ m = 'The value of the {!r} option is {!r} which must be a ' \
'subdir of the prefix {!r}.\nNote that if you pass a ' \ 'subdir of the prefix {!r}.\nNote that if you pass a ' \
'relative path, it is assumed to be a subdir of prefix.' 'relative path, it is assumed to be a subdir of prefix.'

@ -702,31 +702,6 @@ def Popen_safe_legacy(args, write=None, stderr=subprocess.PIPE, **kwargs):
e = e.decode(errors='replace').replace('\r\n', '\n') e = e.decode(errors='replace').replace('\r\n', '\n')
return p, o, e 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): def iter_regexin_iter(regexiter, initer):
''' '''
Takes each regular expression in @regexiter and tries to search for it in Takes each regular expression in @regexiter and tries to search for it in

@ -279,8 +279,8 @@ def run_script_command(args):
return cmdfunc(cmdargs) return cmdfunc(cmdargs)
def run(original_args, mainfile=None): def run(original_args, mainfile=None):
if sys.version_info < (3, 4): if sys.version_info < (3, 5):
print('Meson works correctly only with python 3.4+.') print('Meson works correctly only with python 3.5+.')
print('You have python %s.' % sys.version) print('You have python %s.' % sys.version)
print('Please update your environment') print('Please update your environment')
return 1 return 1

@ -191,26 +191,6 @@ class InternalTests(unittest.TestCase):
l.append_direct('-lbar') l.append_direct('-lbar')
self.assertEqual(l, ['-Lfoodir', '-lfoo', '-Lbardir', '-lbar', '-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): def test_string_templates_substitution(self):
dictfunc = mesonbuild.mesonlib.get_filenames_templates_dict dictfunc = mesonbuild.mesonlib.get_filenames_templates_dict
substfunc = mesonbuild.mesonlib.substitute_values substfunc = mesonbuild.mesonlib.substitute_values

Loading…
Cancel
Save