【问题标题】:installing only .pyc (python compiled) with setuptools使用 setuptools 仅安装 .pyc(python 编译)
【发布时间】:2011-08-09 11:55:06
【问题描述】:

我想运行python setup.py install(安装脚本使用setuptools),并且我只想将.pyc 文件包含在生成的egg 或目录中。不得存在所有 .py 文件。我该怎么做?

【问题讨论】:

  • 编写一个脚本读取 ZIP 文件并删除所有不相关的文件...这是一个三行。
  • @restrisiko:同意,但也许有一个标准的 setuptools 方法可以做到这一点,如果是这样的话,我想了解一些关于我正在使用的工具的新知识。

标签: python setuptools


【解决方案1】:

不是install,但可能是运行以下命令

python setup.py bdist_egg --exclude-source-files

然后使用 easy_install 在 dist 中安装生成的 egg

easy_install dist/eggname.egg

请注意,according to the manual install 只不过是使用 easy_install 的快捷方式。

【讨论】:

  • 这将与 python3 中断,因为字节码文件位于 pychache 中,除非源文件根据 this 存在,否则 python 解释器不会在那里查找
  • @giskou 我测试过,它在Python 3下工作。由于生成的pyc文件的名称与原始py文件的名称匹配,因此可以被解释器定位。
猜你喜欢
  • 2014-04-16
  • 1970-01-01
  • 2013-12-05
  • 2016-01-15
  • 1970-01-01
  • 2014-10-02
  • 1970-01-01
  • 1970-01-01
  • 2013-12-15
相关资源
最近更新 更多