'Utilising Cython with Pyinstaller
I am trying to build a program in python using Cython and PyInstaller. Before starting, I built this test program. However, the two modules aren't working together at all. I have tried them both separately, and they work. I looked at this question but that doesn't work.
I also tried using cython to compile it to c and then use gcc, but that doesn't work either (I added the python.h file, and gcc just aborts after complaining that the keyword doesn't exist)
#hello.pyx
import pygame
def say_hello_to(name):
print("Hello %s!" % name)
#hello.py
from hello import say_hello_to
say_hello_to('Me')
#setup.py
from setuptools import setup
from Cython.Build import cythonize
setup(
name='Hello world app',
ext_modules=cythonize("hello.pyx"),
zip_safe=False,
)
All of this works in CPython, with :
python3 setup.py build_ext --inplace
Then
python3 hello.py
But PyInstaller
keeps complaining it can't find the module hello. I tried add-data and add-binaries, as well as editing the spec file, and it still doesn't work, saying:
invalid add_data_or_binary value: 'home:Achyut-BK:hello.cpython-38-x86_64-linux-gnu.so'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|