crossplatform py2exe - 它会有用吗? [英] crossplatform py2exe - would it be useful?

查看:74
本文介绍了crossplatform py2exe - 它会有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个新版本的py2exe,它需要

Python 2.3及更高版本,因为它使用了zipimport机制。


由于py2exe是一个distutils扩展,并且由于C编译器在Windows以外的大多数平台上都是常用的,所以很容易让py2exe生成一个C源文件。安装这个导入钩子,

并让distutils的'C编译器从中构建一个可执行文件。


这会有用,还是会浪费我的时间,因为McMillan

安装程序,cx_freeze和tools / freeze已经完成了吗?


在这篇文章的最后你会找到摘录自述文件,其中

是目前唯一可用的文件。


Thomas


自述文件:


Python 2.3的新改进的py2exe

======================== ================


使用zipimport机械装置anism,所以它需要Python 2.3或更高版本。

zipimport机制能够处理早期导入的

警告以及由Python完成的编码模块。


创建一个目录,必须完全部署。


(大部分基于Mark Hammond的想法:)可以创建任何

数字此目录中的控制台和gui可执行文件,以及

可选的Windows服务exe,以及可选的exe和dll com

服务器。 com服务器可以公开一个或多个com对象类。


所有纯Python文件都包含在一个zip存档中,这是由所有人共享的
可执行文件。 zip存档也可以由嵌入Python的
程序使用。由于无法从zip文件导入扩展模块

,因此zip文件中包含一个简单的纯Python加载器

,它从文件系统加载扩展(不需要

目录在sys.path中。


如果可执行文件只能运行一个

sys就好了。包含zipfile的绝对文件名的路径条目,但是对于dll com服务器来说似乎是
,可执行文件的目录也需要
。绝对文件名在运行时从包含可执行文件的

目录构建,并且在

构建时指定了zipfile名称。


方式改变了在设置

脚本中指定构建目标的方式。 py2exe安装它自己的Distribution子类,它为setup函数启用了另外的关键字参数:


console = [...]#要转换的脚本列表进入控制台可执行文件

windows = [...]#转换为gui可执行文件的脚本列表

com_servers = [...]#完全限定类名列表构建到exe com服务器中

service = [...]#构建成服务可执行文件的完全限定类名列表

zipfile =" xxx.zip"包含纯Python模块的zipfile的#filename

以上所有参数都是可选的。 zip文件名默认为

''library.zip''。

I''m currently working on a new version of py2exe, which will require
Python 2.3 and later, because it uses the zipimport mechanism.

Since py2exe is a distutils extension, and since C compilers are
commonly available on most platforms except Windows, it would be fairly
easy to let py2exe generate a C source file installing this import hook,
and let distutils'' C compiler build an executable file from this.

Would this be useful, or would I be wasting my time, since McMillan
installer, cx_freeze, and tools/freeze already do it?

At the end of this post you''ll find excerpts from the readme file, which
is currently the only documentation available.

Thomas

The readme file:

A new and improved py2exe for Python 2.3
========================================

Uses the zipimport mechanism, so it requires Python 2.3 or later. The
zipimport mechanism is able to handle the early imports of the
warnings and also the encodings module which is done by Python.

Creates a single directory, which must be deployed completely.

(Most of this is based on ideas of Mark Hammond:) Can create any
number of console and gui executables in this directory, plus
optionally a windows service exe, plus optionally an exe and dll com
server. The com servers can expose one or more com object classes.

All pure Python files are contained in a single zip archive, which is
shared by all the executables. The zip archive may also be used by
programs embedding Python. Since extension modules cannot be imported
from zipfiles, a simple pure Python loader is included in the zipfile
which loads the extension from the file system (without requiring that
the directory is in sys.path).

It would be nice if the executables could be run with only a single
sys.path entry containing the absolute filename of the zipfile, but it
seems for dll com servers the executable''s directory is also
needed. The absolute filenames are constructed at runtime from the
directory containing the executable, and the zipfile name specified at
build time.

The way has changed how build targets are specified in the setup
script. py2exe installs it own Distribution subclass, which enables
additional keyword arguments to the setup function:

console = [...] # list of scripts to convert into console executables
windows = [...] # list of scripts to convert into gui executables
com_servers = [...] # list of fully qualified class names to build into the exe com server
service = [...] # list of fully qualified class names to build into a service executable
zipfile = "xxx.zip" # filename of the zipfile containing the pure Python modules

All of the above arguments are optional. The zipfile name defaults to
''library.zip''.

推荐答案

嗨Thomas;


之前我曾尝试过Freeze,但是我迷上了py2exe,因为它非常简单,而且很灵活,可以自动处理所有奇怪的情况。 。

对于我们这些不是C大师的人来说,欢迎任何使这个过程变得更容易的事情。


为了澄清你的提议,你是否只需在其他平台上使用

构建可执行文件相同的setup.py脚本,或者你需要做什么?b $ b做更多的手动步骤? br />

感谢迄今为止的出色工作... py2exe ROCKS!问:]


Kevin。

Thomas Heller< th ***** @ python.net>在消息新闻中写道:< pt ********** @ python.net> ...
Hi Thomas;

I''ve tried Freeze before, but I''m hooked on py2exe because it''s so
SIMPLE and flexible, and handles all the weird cases automatically...
For those of us that aren''t C gurus, anything that makes the process
easier is welcome.

To clarify your proposal, would you simply build the executable using
the same setup.py script on other platforms too, or would you have to
do more manual steps?

Thanks for the great work so far... py2exe ROCKS! q:]

Kevin.
Thomas Heller <th*****@python.net> wrote in message news:<pt**********@python.net>...
我正在研究新版本的py2exe,这将需要
Python 2.3及更高版本,因为它使用了zipimport机制。

因为py2exe是一个distutils扩展,并且由于C编译器通常可以在除Windows之外的大多数平台上使用,它会相当容易让py2exe生成一个安装这个导入钩子的C源文件,然后让distutils的'C编译器从中构建一个可执行文件。

这会有用吗或者我会浪费我的时间,因为McMillan
安装程序,cx_freeze和tools / freeze已经这样做了吗?

在这篇文章的最后,你会看到自述文件的摘录文件,这是目前唯一可用的文档。

托马斯

自述文件:

Python的一个新的和改进的py2exe 2.3
========================================

使用zipimport机制,因此它需要Python 2.3或更高版本。
zipimport机制能够处理早期导入的
警告以及由Python完成的编码模块。

创建一个必须完全部署的目录。

(大多数是基于Mark Hammond的想法:)可以在这个目录中创建任何数量的控制台和gui可执行文件,以及可选的Windows服务exe,加上可选的exe和dll com
服务器。 com服务器可以公开一个或多个com对象类。

所有纯Python文件都包含在一个zip存档中,由所有可执行文件共享。 zip存档也可以由嵌入Python的程序使用。由于无法从zip文件导入扩展模块,因此zipfile中包含一个简单的纯Python加载器,用于从文件系统加载扩展(无需将目录放在sys.path中)如果可执行文件只能运行包含zipfile的绝对文件名的单个
sys.path条目,那将是很好的,但它似乎对于dll com来说服务器还需要可执行文件的目录。绝对文件名是在运行时从包含可执行文件的
目录构建的,并且在构建时指定了zipfile名称。

这种方式改变了构建目标的方式。设置
脚本。 py2exe安装它自己的Distribution子类,它为安装功能启用了额外的关键字参数:

console = [...]#转换为控制台可执行文件的脚本列表
windows = [...]#转换为gui可执行文件的脚本列表
com_servers = [...]#构建到exe com服务器的完全限定类名列表
service = [... ]#要构建成服务可执行文件的完全限定类名列表
zipfile =" xxx.zip"包含纯Python模块的zipfile的#filename

所有上述参数都是可选的。 zip文件名默认为
''library.zip''。
I''m currently working on a new version of py2exe, which will require
Python 2.3 and later, because it uses the zipimport mechanism.

Since py2exe is a distutils extension, and since C compilers are
commonly available on most platforms except Windows, it would be fairly
easy to let py2exe generate a C source file installing this import hook,
and let distutils'' C compiler build an executable file from this.

Would this be useful, or would I be wasting my time, since McMillan
installer, cx_freeze, and tools/freeze already do it?

At the end of this post you''ll find excerpts from the readme file, which
is currently the only documentation available.

Thomas

The readme file:

A new and improved py2exe for Python 2.3
========================================

Uses the zipimport mechanism, so it requires Python 2.3 or later. The
zipimport mechanism is able to handle the early imports of the
warnings and also the encodings module which is done by Python.

Creates a single directory, which must be deployed completely.

(Most of this is based on ideas of Mark Hammond:) Can create any
number of console and gui executables in this directory, plus
optionally a windows service exe, plus optionally an exe and dll com
server. The com servers can expose one or more com object classes.

All pure Python files are contained in a single zip archive, which is
shared by all the executables. The zip archive may also be used by
programs embedding Python. Since extension modules cannot be imported
from zipfiles, a simple pure Python loader is included in the zipfile
which loads the extension from the file system (without requiring that
the directory is in sys.path).

It would be nice if the executables could be run with only a single
sys.path entry containing the absolute filename of the zipfile, but it
seems for dll com servers the executable''s directory is also
needed. The absolute filenames are constructed at runtime from the
directory containing the executable, and the zipfile name specified at
build time.

The way has changed how build targets are specified in the setup
script. py2exe installs it own Distribution subclass, which enables
additional keyword arguments to the setup function:

console = [...] # list of scripts to convert into console executables
windows = [...] # list of scripts to convert into gui executables
com_servers = [...] # list of fully qualified class names to build into the exe com server
service = [...] # list of fully qualified class names to build into a service executable
zipfile = "xxx.zip" # filename of the zipfile containing the pure Python modules

All of the above arguments are optional. The zipfile name defaults to
''library.zip''.



Thomas Heller写道:
Thomas Heller wrote:
我目前正在开发一个新版本的py2exe,它需要使用Python 2.3及更高版本,因为它使用了zipimport机制。

因为py2exe是一个distutils扩展,并且由于C编译器通常可以在除Windows之外的大多数平台上使用,因此很容易让py2exe生成安装此导入钩子的C源文件,并让distutils的'C编译器构建这是一个可执行文件。

这会有用,还是我会浪费我的时间,因为McMillan
安装程序,cx_freeze和tools / freeze已经这样做了?
I''m currently working on a new version of py2exe, which will require
Python 2.3 and later, because it uses the zipimport mechanism.

Since py2exe is a distutils extension, and since C compilers are
commonly available on most platforms except Windows, it would be fairly
easy to let py2exe generate a C source file installing this import hook,
and let distutils'' C compiler build an executable file from this.

Would this be useful, or would I be wasting my time, since McMillan
installer, cx_freeze, and tools/freeze already do it?




我认为这将是一个非常棒的想法:py2exe是你提到的所有工具中最简单的使用

,它会节省大量的墨水^ H ^ H ^ H像素,每次我指向人们时,
为ab le省略了关于if

你有兴趣仅部署到Windows平台,然后...... :-)的模糊。

Alex



I think it would be a WONDERFUL idea: py2exe is the simplest to use
of all the tools you mention, and it would save a lot of ink^H^H^H pixels,
each time I point people to it, to be able to omit the blurb about "if
you''re interested in deploying to Windows platform only, then"...:-).
Alex


2003年8月6日星期三下午08:36:20 +0200,Thomas Heller写道:
On Wed, Aug 06, 2003 at 08:36:20PM +0200, Thomas Heller wrote:
我正在工作在新版本的py2exe上,需要使用Python 2.3及更高版本,因为它使用了zipimport机制。
I''m currently working on a new version of py2exe, which will require
Python 2.3 and later, because it uses the zipimport mechanism.




现在zipimport是Python的一部分引导所需的代码

a py2exe运行时只是:


myscript -c" import sys; sys.path.insert(0,sys.executable);导入foo"


这减少了

py2exe提供的自定义解释器与标准解释器之间的差异,只需几行C.


显而易见的问题是 - 为什么不一直这样把这个小的

挂钩放到标准的Python发行版中?这样py2exe可以是一个独立于平台的纯Python应用程序。事实上,py2exe实际上不需要
因为任何人都可以手动创建一个zip文件并且

将它附加到可执行文件但是更方便一个工具,

自动化过程并找到所需的依赖关系。


Oren



Now that zipimport is part of Python the code required for bootstrapping
a py2exe runtime is just:

myscript -c "import sys; sys.path.insert(0, sys.executable); import foo"

This reduces the difference between the custom interpreter supplied with
py2exe and the standard interpreter to just a few lines of C.

The obvious question is - why not go all the way and put this little
hook into the standard Python distribution? This way py2exe could be a
platform-independent pure Python application. In fact, py2exe wouldn''t
actually be necessary because anyone could create a zip file manually and
append it to the executable but it''s more convenient to have a tool that
automates the process and finds the required dependencies.

Oren


这篇关于crossplatform py2exe - 它会有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆