我创建了一个Python Egg;现在怎么办?
我终于弄清楚了如何创建一个 Python Egg 并让它工作。现在...我该怎么办?我该如何使用它?我如何确保所有内容都正确包含在内? (请简单的步骤......不仅仅是重定向到另一个网站。我用谷歌搜索过,但这让我感到困惑,我希望有人可以用几个简单的要点或句子来解释它。)
编辑:
我几周前问过这个问题,现在我正在澄清,希望得到更清晰的答案......基本上,我有一个鸡蛋,我想把它带到另一台机器上并能够使用它并且从我的(其他不相关的)代码中导入模块。我该怎么做?
I've finally figured out how to create a Python egg and gotten it to work. Now... what do I do with it? How do I use it? How do I ensure that everything was correctly included? (Simple steps please... not just redirection to another site. I've googled, but it's confusing me, and I was hoping someone could explain it in a couple of simple bullet points or sentences.)
Edit:
I asked this question a couple of weeks ago, and I'm clarifying now in the hope of getting clearer answers... basically, I have an egg, I want to take it to another machine and be able to use it and import modules from it from my (other, unrelated) code. How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议仅使用 python setup.py sdist 来创建 zip 和/或 tarball,并跳过鸡蛋。
如果你想查看鸡蛋,它是一个 zip 文件;您可以使用
unzip -v MyEgg-0.1.egg
并查看其内容,看看是否包含您期望的所有文件。您也可以尝试安装它。使用 virtualenv 创建新环境(使用--no-site-packages
来创建它被隔离)并尝试将其安装到该环境中,例如:然后看看是否可以导入它并像您期望的那样使用您的包。您也可以执行所有相同的操作来测试 sdist。
I'd advise only using
python setup.py sdist
to create zips and/or tarballs, and skip eggs.If you want to look at the egg it is a zip file; you can use
unzip -v MyEgg-0.1.egg
and see its contents to see if includes all the files you expect. You can also try installing it. Use virtualenv to create a new environment (use--no-site-packages
to make it isolated) and try installing it into that environment, like:And then see if you can import it and use your package like you expect. You can do all the same things to test an sdist too.
我最终做的是:
PYTHONPATH=fullPathOfMyEgg
import someModuleInMyEgg
我不确定这是否是最标准的或接受的方式来做到这一点,但它有效。如果大家有什么意见或者其他方法,欢迎补充...
What I ended up doing was:
PYTHONPATH=fullPathOfMyEgg
in command lineimport someModuleInMyEgg
from my Python codeI'm not sure if this is the most standard or accepted way to do it, but it worked. If anyone has any comments or other methods, please feel free to add...