cython编译python exe,Cython编译的EXE需要Python安装才能运行

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?

解决方案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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值