Задать вопрос
qwertiss
@qwertiss
Тупо на чиле, на расслабоне

Проблема с компиляцией .pyd в Nuitka: «SyntaxError: invalid or missing encoding declaration»?

Я пытаюсь скомпилировать .pyd помощью nuitka 2.6.4.
.pyd скопилил через cython

python setup.py build_ext --inplace

from setuptools import setup
from Cython.Build import cythonize

setup(
    ext_modules=cythonize("main.py", compiler_directives={"language_level": "3"})
)


Сначала использовал Python 3.9.1.
python3.9 -m nuitka --standalone --windows-console-mode=disable --enable-plugin=tk-inter main.cp39-win_amd64.pyd


Вывод получился таким
Nuitka-Options: Used command line options: --standalone --show-scons --windows-console-mode=disable
Nuitka-Options: --enable-plugin=tk-inter main.cp39-win_amd64.pyd
Nuitka: Starting Python compilation with Nuitka '2.6.4' on Python (flavor Unknown), '3.9' commercial grade 'not
Nuitka: installed'.
SyntaxError: invalid or missing encoding declaration for 'main.cp39-win_amd64.pyd'

Nuitka is very syntax compatible with standard Python. It is currently running
with Python version '3.9', you might want to specify more clearly with the use
of the precise Python interpreter binary and '-m nuitka', e.g. use this
'python3.13 -m nuitka' option, if that's not the one the program expects.


Подумал, ладно, кодировку не указал.

# -*- coding: utf-8 -*-
set PYTHONIOENCODING=utf-8


Всё равно не помогло.
Попробовал поставить Python3.13, 3.10.
Всё та же ситуация.

Может я что не правильно делаю и nuitka вообще не работает .pyd? Или я упускаю что-то. Помогите пожалуйста.
  • Вопрос задан
  • 119 просмотров
Подписаться 1 Средний 2 комментария
Решения вопроса 1
qwertiss
@qwertiss Автор вопроса
Тупо на чиле, на расслабоне
Короче, извиняюсь за путаницу. Прочитал недостоверную инфу и повёлся.
Итог таков, .pyd не компилиться в Nuitka
Nuitka работает только с .py и в C++/C сама уже собирает (для этого собственно и качается отдельно gcc mingw64).
Изначально хотел сделать код более нечитабельным и сложно декомпилируемым, потому решил так заморочиться.

В общем, решил забить и нашёл в докумке аргументы для сборки, которые хотел воплотить с Cython.
--lto=yes --nofollow-import-to=unittest --nofollow-import-to=pytest --nofollow-import-to=pdb --assume-yes-for-downloads --remove-output --noinclude-pytest-mode=nofollow --noinclude-setuptools-mode=nofollow
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы