简体   繁体   English

为ubuntu linux编译python,cx_python

[英]Compiling python for ubuntu linux, cx_python

I need to be able to distribute my python script, preferably in linux byte code. 我需要能够分发我的python脚本,最好以linux字节码分发。 It has several dependencies that are located in directories as such: 它具有几个位于目录中的依赖项,例如:

extensions
    python  >> run.py
    python  >> protocols.py
    plugins >> Folder contains more run.py dependencies
    bash    >> Contains bash scripts needed

I've tried simply cd-ing to extensions/python and running cxfreeze run.py. 我已经尝试过简单地将CD扩展到cd / python并运行cxfreezerun.py。 However, this creates several files in a dist folder, none of which (including 'run' are executable. There are no 'make' instructions created in this directory. 但是,这会在dist文件夹中创建多个文件,这些文件都不包含(包括“ run”是可执行文件。)在此目录中未创建“ make”指令。

How would I do this? 我该怎么做? :) :)

I would use the Python 2.6+ feature of executing zip files. 我将使用执行zip文件的Python 2.6+功能。 See an elaborate blog article ; 看到一篇详细的博客文章 ; in short: 简而言之:

  1. create .pyc files for all your modules, eg by importing them once 为所有模块创建.pyc文件,例如,一次导入
  2. write an __main__.py 写一个__main__.py
  3. zip up the __main__.py , and all .pyc files, eg as foo.zip 压缩__main__.py和所有.pyc文件,例如foo.zip
  4. test, using python foo.zip 使用python foo.zip测试
  5. prepend a line #!/usr/bin/python to the zip file (eg with echo and cat) 在zip文件之前添加#!/usr/bin/python行(例如,带有echo和cat)
  6. set the x bit on the resulting file 在结果文件上设置x位

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM