python预编译标准库,在预编译的字节码+所有必需的库中分发python脚本

I made a (one file) scrip in python for my client, the program is a success and now it needs to be distributed to 12 of my client employees.

The script I made uses a lot of libraries (imports), some of then are not popular at all so here goes the question:

Is there a way to distribute my program already compiled in bytecode? So the users can run it by just simply doing "python myProgram.pyc" or just "myProgram.pyc" (if it has +x property), I know this is entirely possible in Java by compiling the libraries inside a JAR file, is there anything similar for python?

Please don't recommend me py2exe since is far away for what I want, either other similar tools, I just want to distribute a package with all the necessary libraries already pre-compiled in bytecode so the final users don't need to worry about installing libs, pip, github, custom stuff, or anything. Hope you can help me, if not I will have to port the whole project to Java.

解决方案

If your client employees machine are Windows go for py2exe http://py2exe.org/

cx_Freeze http://cx-freeze.sourceforge.net/ is cross-platform and it should spit out executable that would run on any OS with Python installed.

PyInstaller http://www.pyinstaller.org/ is a good one too.

However, these methods do not compile and hence improve run-time performance improvements. Rather a way to distribute your script as a single executable with all the necessary modules.

You could use the compiled .pyc file with a wrapper around it for execution and package it as a single executable. However, performance improvements of doing so is debatable.

EDIT:

It's been long though, recently started with cython and it could be a plausible solution for this problem. If not all, defining the variable types should do that is asked in the question.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值