нуитка: как использовать --include-plugin-files? - PullRequest
0 голосов
/ 14 апреля 2020

Я пытаюсь скомпилировать очень простой скрипт pygame, используя nuitka. Это скрипт (main.py)

import pygame

pygame.init()
screen = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
done = False

font = pygame.font.SysFont("comicsansms", 72)

text = font.render("Hello World", True, (0, 128, 0))

while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            done = True

    screen.fill((255, 255, 255))
    screen.blit(text,
        (320 - text.get_width() // 2, 240 - text.get_height() // 2))

    pygame.display.flip()
    clock.tick(60)

Сначала я попытался скомпилировать его с помощью: python3 -m nuitka --standalone main.py, что привело ко всем этим предупреждениям (но закончено):

Nuitka:WARNING:Use '--plugin-enable=numpy' for: numpy support.
Nuitka:WARNING:Unresolved '__import__' call at '/usr/lib/python3/dist-packages/OpenGL/plugins.py:38' may require use of '--include-plugin-directory' or '--include-plugin-files'.
Nuitka:WARNING:Unresolved '__import__' call at '/usr/lib/python3/dist-packages/numpy/core/function_base.py:453' may require use of '--include-plugin-directory' or '--include-plugin-files'.
Nuitka:WARNING:Unresolved '__import__' call at '/usr/lib/python3/dist-packages/numpy/lib/utils.py:366' may require use of '--include-plugin-directory' or '--include-plugin-files'.
Nuitka:WARNING:Unresolved '__import__' call at '/usr/lib/python3/dist-packages/numpy/lib/utils.py:865' may require use of '--include-plugin-directory' or '--include-plugin-files'.
Nuitka:WARNING:Unresolved '__import__' call at '/usr/lib/python3/dist-packages/numpy/lib/utils.py:923' may require use of '--include-plugin-directory' or '--include-plugin-files'.

Когда запустив получившийся двоичный файл, открывается черное окно, которое затем вылетает с:

Fatal Python error: (pygame parachute) Segmentation Fault
Traceback (most recent call last):
  File "/home/xxxxx/git/sesyn/paradigm10123/main.dist/pygame/pkgdata.py", line 51, in getResource
  File "/home/xxxxx/git/sesyn/paradigm10123/main.dist/pkg_resources/__init__.py", line 1134, in resource_exists
  File "/home/xxxxx/git/sesyn/paradigm10123/main.dist/pkg_resources/__init__.py", line 1404, in has_resource
  File "/home/xxxxx/git/sesyn/paradigm10123/main.dist/pkg_resources/__init__.py", line 1473, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
Aborted (core dumped)

Так что я изменил функцию getResource, где она вылетала, для распечатки файлов, которые он пытается загрузить. Затем я добавил эти файлы с помощью команды --include-plugin-files: python3 -m nuitka --standalone main.py --include-plugin-files=/home/xxxxx/.local/lib/python3.7/site-packages/pygame/pygame_icon.bmp --include-plugin-files=/home/xxxxx/.local/lib/python3.7/site-packages/pygame/freesansbold.ttf, но при запуске полученного двоичного файла получился тот же самый cra sh.

Я также попытался добавить каталог OpenGL в качестве plugin-dir и использовал * Плагин 1023 * (я не знаю о каком-либо использовании numpy здесь, но, эй, я подумал, что это не повредит)

python3 -m nuitka --standalone main.py --include-plugin-files=/home/xxxxx/.local/lib/python3.7/site-packages/pygame/pygame_icon.bmp --include-plugin-files=/home/xxxxx/.local/lib/python3.7/site-packages/pygame/freesansbold.ttf --include-plugin-directory=/usr/lib/python3/dist-packages/OpenGL/ --enable-plugin=numpy (который сейчас компилируется примерно за 30 минут), но полученный бинарный код все еще производит точно такой же cra sh. Кто-нибудь знает, как сделать этот запуск?

Да, кстати, я использую систему python в Ubuntu 19.10

$ python3 -c "import pygame"
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
$ python3 -m nuitka --version
0.6.7
Python: 3.7.5 (default, Nov 20 2019, 09:21:52) 
Executable: /usr/bin/python3
OS: Linux
Arch: x86_64
$ gcc --version
gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
...