问题
I have compiled my python code (in Windows) with the following cython and gcc commands:-
cython --embed -o hello.c hello.py
gcc -municode -mthreads -Wall -O -IC:\Python37\include -LC:\Python37\libs hello.c -lpython37 -Wl,--subsystem,windows -o hello.exe
(I am using modules such as request, pysimpleguiqt and fdb in hello.py)
The resulting exe requires python installation to execute. Is there any way to compile it without the need of python installation at runtime?
回答1:
Is there any way to compile it without the need of python installation at runtime?
Perhaps technically yes (with some your improvements to Cython) but then ....
the resulting executable might be illegal to redistribute
(if you use static linking and did not get legally proper software licenses)
Read carefully again all open source licenses involved with Python and all your dependencies, even indirect ones and show them (with the EULA governing your Windows system) to your lawyer.
If you are coding something in a professional setting, consider coding it in some other language than Python. Be aware of tivoization.
I am not a lawyer
Consult your lawyer for software license issues. The topic is really complex and requires help from a professional lawyer, especially for executables that are shipped worldwide or embedded in some device. Software related laws are different in the USA and in France (and probably even in various states of the USA) or in India or China.
The resulting exe requires python installation to execute
That is expected and normal. Related topic is called DLL hell.
(I am using modules such as request, pysimpleguiqt and fdb in hello.py)
PySimpleGuiQt is depending upon Qt. So you'll need a Qt license for Windows, if you want to legally distribute the resulting executable (if your code is embedded, you'll need a Qt license for the embedded system). fdb has a different license.
See also https://opensource.stackexchange.com/
You could also (with prior approval from your manager or client) release and distribute your software under GPLv3+ and have your lawyer check that all software licenses are compatible and legal...
You might recode a Python bytecode interpreter using your own JIT compilation libraries. This should take at least months and the resulting executable might be legal (if you bought a Qt license at least).
you need a lawyer
PS. I am personally member of APRIL, a French non-profit association promoting open source software. Even in France, the legal topic is really difficult. If your employer or client is selling your software (with license violation) in France, I expect APRIL to go to court against your product. Legal precedents are favorable (unless of course a proper Qt license has been bought). Some legal cases went to Court of Cassation, and APRIL won.
NB. I professionally wrote some research grants proposals related to rewriting Cython like suggested above. As often, the legal issues are the most difficult to write about. That grant was not funded. See for example Systematic competitiveness cluster. They wrote in French a document about licensing issues in French law.
来源:https://stackoverflow.com/questions/61926457/cython-compiled-exe-needs-python-installation-to-run