【发布时间】:2024-05-30 03:50:01
【问题描述】:
我隐约记得某种 setuptools 包装器,它会从 distutils 源代码生成 .egg 文件。有人能唤起我的记忆吗?
【问题讨论】:
标签: python setuptools distutils
我隐约记得某种 setuptools 包装器,它会从 distutils 源代码生成 .egg 文件。有人能唤起我的记忆吗?
【问题讨论】:
标签: python setuptools distutils
setuptools 会在 distutils 导入时对其某些部分进行猴子补丁。当你使用 easy_install 从 PyPI 获取基于 distutils 的项目时,它会创建一个 egg(pip 也可以这样做)。要在本地执行相同的操作(即在代码签出或解压缩的 tarball 目录中),请使用以下技巧:python -c "import setuptools; execfile('setup.py')" bdist_egg。
【讨论】:
execfile 消失了,所以你需要像 python -c "import setuptools; exec(open('setup.py').read())" bdist_egg 这样的东西。
你试过了吗
python setup.py bdist_egg
这里我假设您使用的是 setuptools 而不是 distutils 即
在 setup.py 中而不是
from distutils.core import setup
使用
from setuptools import setup
【讨论】: