如何解决如何与 Meson 和 Python 依赖项交叉编译?
我正在尝试使用 Meson 交叉编译应用程序。该应用程序具有 Python 依赖项。 我正在 Linux 系统(构建机器)上构建,并且正在构建 Windows 可执行文件(主机)。
我无法让 Meson 检测 Python 依赖项。
这是我试过的。我的 meson.build 使用的是 Meson 的 Python 模块:
pymod = import('python')
python = pymod.find_installation('python3')
pybind11_include_dir = include_directories('./include')
pybind11_dep = declare_dependency(
compile_args : [
# see https://github.com/pybind/pybind11/issues/1604
'-fsized-deallocation','-fvisibility=hidden'
],include_directories : pybind11_include_dir,dependencies : [
python.dependency()
],)
这在我构建本机 Linux 可执行文件时有效。当我为 Windows 交叉编译时,我在本地有一个 Windows 版本的 Python。我在 cross_file.txt 中这样指出(我省略了 mingw64 工具链部分以及主机和构建机器设置):
[binaries]
python = '/home/user/src/mingw/py38/python.exe'
[built-in options]
c_args = ['-I/home/user/src/mingw/py38/include','-L/home/user/src/mingw/py38']
cpp_args = ['-I/home/user/src/mingw/py38/include','-L/home/user/src/mingw/py38']
现在,当我运行 meson setup build_win64 --buildtype=debugoptimized --cross-file cross_file.txt
时,介子找到了 python 可执行文件,但随后尝试执行。这是行不通的,因为它是 Windows 二进制文件:
Program python3 found: YES (/home/user/src/mingw/py38/python.exe)
OPENING: ['/home/user/src/mingw/py38/python.exe','-c',"import sysconfig\nimport json\nimport sys\n\ninstall_paths = sysconfig.get_paths(scheme='posix_prefix',vars={'base': '','platbase': '','installed_base': ''})\n\ndef links_against_libpython():\n from distutils.core import Distribution,Extension\n cmd = Distribution().get_command_obj('build_ext')\n cmd.ensure_finalized()\n return bool(cmd.get_libraries(Extension('dummy',[])))\n\nprint (json.dumps ({\n 'variables': sysconfig.get_config_vars(),\n 'paths': sysconfig.get_paths(),\n 'install_paths': install_paths,\n 'version': sysconfig.get_python_version(),\n 'platform': sysconfig.get_platform(),\n 'is_pypy': '__pypy__' in sys.builtin_module_names,\n 'link_libpython': links_against_libpython(),\n}))\n"]
Traceback (most recent call last):
-- snip ---
File "/usr/lib64/python3.6/subprocess.py",line 1364,in _execute_child
raise child_exception_type(errno_num,err_msg,err_filename)
OSError: [Errno 8] Exec format error: '/home/user/src/mingw/py38/python.exe'
Meson Python 模块文档根本没有提到交叉编译。
让Meson在Linux下找到Windows Python依赖设置的正确方法是什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。