Can run argument strings with internal Python. Closes #5217.

pull/5300/head
Jussi Pakkanen 6 years ago
parent ce160e1eab
commit 4e4f97edb3
  1. 4
      mesonbuild/mesonmain.py
  2. 8
      mesonbuild/modules/python.py
  3. 24
      msi/createmsi.py

@ -81,11 +81,15 @@ class CommandLineParser:
self.commands[i] = p
def add_runpython_arguments(self, parser):
parser.add_argument('-c', action='store_true', dest='eval_arg', default=False)
parser.add_argument('script_file')
parser.add_argument('script_args', nargs=argparse.REMAINDER)
def run_runpython_command(self, options):
import runpy
if options.eval_arg:
exec(options.script_file)
else:
sys.argv[1:] = options.script_args
sys.path.insert(0, os.path.dirname(options.script_file))
runpy.run_path(options.script_file, run_name='__main__')

@ -42,9 +42,8 @@ mod_kwargs -= set(['name_prefix', 'name_suffix'])
def run_command(python, command):
_, stdout, _ = mesonlib.Popen_safe(python.get_command() + [
'-c',
command])
cmd = python.get_command() + ['-c', command]
_, stdout, _ = mesonlib.Popen_safe(cmd)
return stdout.strip()
@ -265,8 +264,7 @@ class PythonDependency(ExternalDependency):
return super().get_pkgconfig_variable(variable_name, kwargs)
INTROSPECT_COMMAND = '''
import sysconfig
INTROSPECT_COMMAND = '''import sysconfig
import json
import sys

@ -84,6 +84,28 @@ class PackageGenerator:
modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')]
return modules
def get_more_modules(self):
# Python packagers want to minimal and only copy the things that
# they can see that are used. They are blind to many things.
return ['distutils.archive_util',
'distutils.cmd',
'distutils.config',
'distutils.core',
'distutils.debug',
'distutils.dep_util',
'distutils.dir_util',
'distutils.dist',
'distutils.errors',
'distutils.extension',
'distutils.fancy_getopt',
'distutils.file_util',
'distutils.spawn',
'distutils.util',
'distutils.version',
'distutils.command.build_ext',
'distutils.command.build',
]
def build_dist(self):
for sdir in self.staging_dirs:
if os.path.exists(sdir):
@ -91,7 +113,7 @@ class PackageGenerator:
main_stage, ninja_stage = self.staging_dirs
modules = self.get_all_modules_from_dir('mesonbuild/modules')
modules += self.get_all_modules_from_dir('mesonbuild/scripts')
modules += ['distutils.version']
modules += self.get_more_modules()
modulestr = ','.join(modules)
python = shutil.which('python')
cxfreeze = os.path.join(os.path.dirname(python), "Scripts", "cxfreeze")

Loading…
Cancel
Save