modules/python: Allow use of the native file
Currently this just allows setting a "python" variable that always overrides, probably we want to have the option for "python2" and "python3" as well.
This commit is contained in:
parent
091452f8cd
commit
71a5f990d0
|
@ -480,7 +480,9 @@ class PythonModule(ExtensionModule):
|
|||
if len(args) > 1:
|
||||
raise InvalidArguments('find_installation takes zero or one positional argument.')
|
||||
|
||||
if args:
|
||||
if 'python' in state.environment.config_info.binaries:
|
||||
name_or_path = state.environment.config_info.binaries['python']
|
||||
elif args:
|
||||
name_or_path = args[0]
|
||||
if not isinstance(name_or_path, str):
|
||||
raise InvalidArguments('find_installation argument must be a string.')
|
||||
|
|
|
@ -4557,6 +4557,14 @@ class NativeFileTests(BasePlatformTests):
|
|||
def test_python3_module(self):
|
||||
self._simple_test('python3', 'python3')
|
||||
|
||||
def test_python_module(self):
|
||||
if is_windows():
|
||||
# Bat adds extra crap to stdout, so the version check logic in the
|
||||
# python module breaks. This is fine on other OSes because they
|
||||
# don't need the extra indirection.
|
||||
raise unittest.SkipTest('bat indirection breaks internal sanity checks.')
|
||||
self._simple_test('python', 'python')
|
||||
|
||||
|
||||
def unset_envs():
|
||||
# For unit tests we must fully control all command lines
|
||||
|
|
|
@ -14,4 +14,8 @@ elif case == 'python3'
|
|||
prog = import('python3').find_python()
|
||||
result = run_command(prog, ['--version'])
|
||||
assert(result.stdout().strip().endswith('12345'), 'Didn\'t load python3 from config file')
|
||||
elif case == 'python'
|
||||
prog = import('python').find_installation()
|
||||
result = run_command(prog, ['--version'])
|
||||
assert(result.stdout().strip().endswith('12345'), 'Didn\'t load python from config file')
|
||||
endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
option(
|
||||
'case',
|
||||
type : 'combo',
|
||||
choices : ['find_program', 'config_dep', 'python3']
|
||||
choices : ['find_program', 'config_dep', 'python3', 'python']
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue