如何创建Python Egg文件 [英] How to create Python egg file

查看:105
本文介绍了如何创建Python Egg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Python中的鸡蛋文件有疑问.

I have questions about egg files in Python.

我有很多按包组织的Python代码,我正在尝试创建egg文件. 我正在遵循说明,但是它们很常见.

I have much Python code organized by package and I'm trying to create egg files. I'm following instructions, but they are very common.

据此,看来我需要有一个setup.py文件.

According to that, it seems I need to have a setup.py file.

  1. 您能告诉我我需要在setup.py文件中放入什么以及它应该放在哪里吗?
  2. 我想足以创建setup.py,然后启动"setup.py bdist_egg"来获取egg文件.您能确认吗?
  3. 是否可以在egg文件中仅包含.pyc文件?
  4. 拥有.egg文件,如何像java -jar <jar file>一样不解压就可以从中启动代码?
  1. Would you please tell me what I need to put into setup.py file and where it should reside?
  2. I suppose it's enough to create setup.py and then start "setup.py bdist_egg" for getting egg file. Could you please confirm?
  3. Is it possible to include only .pyc files into egg file?
  4. Having .egg file how I can just start the code from it without unpacking like java -jar <jar file> does?

推荐答案

您正在阅读错误的文档.您需要这样做: https://setuptools.readthedocs.io/en/latest/setuptools.html#develop-deploy-the-project-source-in-development-mode

You are reading the wrong documentation. You want this: https://setuptools.readthedocs.io/en/latest/setuptools.html#develop-deploy-the-project-source-in-development-mode

  1. Python的标准库文档中的distutils文档中介绍了创建setup.py的内容.此处. (对于python鸡蛋)主要区别在于您是import setup来自setuptools,而不是distutils.

  1. Creating setup.py is covered in the distutils documentation in Python's standard library documentation here. The main difference (for python eggs) is you import setup from setuptools, not distutils.

是的.没错.

我不这么认为. pyc文件可以是版本和平台相关的.您也许可以打开鸡蛋(它们应该只是zip文件),然后删除.py个文件,而保留.pyc个文件,但是不建议这样做.

I don't think so. pyc files can be version and platform dependent. You might be able to open the egg (they should just be zip files) and delete .py files leaving .pyc files, but it wouldn't be recommended.

我不确定.那可能是开发模式".还是您正在寻找"py2exe"或"py2app"模式?

I'm not sure. That might be "Development Mode". Or are you looking for some "py2exe" or "py2app" mode?

这篇关于如何创建Python Egg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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