我创建了一个Python Egg;现在怎么办?

发布于 2024-09-04 03:01:47 字数 273 浏览 11 评论 0原文

我终于弄清楚了如何创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拒绝两难 2024-09-11 03:01:47

我建议仅使用 python setup.py sdist 来创建 zip 和/或 tarball,并跳过鸡蛋。

如果你想查看鸡蛋,它是一个 zip 文件;您可以使用 unzip -v MyEgg-0.1.egg 并查看其内容,看看是否包含您期望的所有文件。您也可以尝试安装它。使用 virtualenv 创建新环境(使用 --no-site-packages 来创建它被隔离)并尝试将其安装到该环境中,例如:

$ virtualenv --no-site-packages test-env
$ ./test-env/bin/easy_install path/to/MyEgg-0.1.egg
$ ./test-env/bin/python

然后看看是否可以导入它并像您期望的那样使用您的包。您也可以执行所有相同的操作来测试 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:

$ virtualenv --no-site-packages test-env
$ ./test-env/bin/easy_install path/to/MyEgg-0.1.egg
$ ./test-env/bin/python

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.

凉城凉梦凉人心 2024-09-11 03:01:47

我最终做的是:

  1. 在命令行中运行 PYTHONPATH=fullPathOfMyEgg
  2. 然后能够从我的 Python 代码中执行 import someModuleInMyEgg

我不确定这是否是最标准的或接受的方式来做到这一点,但它有效。如果大家有什么意见或者其他方法,欢迎补充...

What I ended up doing was:

  1. Ran PYTHONPATH=fullPathOfMyEgg in command line
  2. Was then able to do import someModuleInMyEgg from my Python code

I'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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文