我能将鸡蛋变成车轮吗?

19

我已经有一个已构建/下载的Python egg,我想将其转换为PEP 427中记录的wheel格式。
我该如何做呢?

2个回答

21

答案是肯定的。
我们只需要 wheel 包,甚至不需要安装它,因为根据文档,我们可以直接使用它(由于 .whl 文件与 .zip 文件具有相同的格式,并且 Python 可以直接运行 .zip 文件中的代码):

pdobrogost@host:~$ python ./wheel-0.22.0-py2.py3-none-any.whl/wheel -h
usage: wheel [-h]

             {keygen,sign,unsign,verify,unpack,install,install-scripts,convert,version,help}
             ...

positional arguments:
  {keygen,sign,unsign,verify,unpack,install,install-scripts,convert,version,help}
                        commands
    keygen              Generate signing key
    sign                Sign wheel
    unsign              Remove RECORD.jws from a wheel by truncating the zip
                        file. RECORD.jws must be at the end of the archive.
                        The zip file must be an ordinary archive, with the
                        compressed files and the directory in the same order,
                        and without any non-zip content after the truncation
                        point.
    verify              Verify a wheel. The signature will be verified for
                        internal consistency ONLY and printed. Wheel's own
                        unpack/install commands verify the manifest against
                        the signature and file contents.
    unpack              Unpack wheel
    install             Install wheels
    install-scripts     Install console_scripts
    convert             Convert egg or wininst to wheel
    version             Print version and exit
    help                Show this help

optional arguments:
  -h, --help            show this help message and exit
现在,我们要做的就是使用convert参数并传递要转换的蛋:
pdobrogost@host:~$ python ./wheel-0.22.0-py2.py3-none-any.whl/wheel convert ./my-egg.egg

感谢Paul Moore在virtualenv的群组中提供的答案,以及在#pip irc频道中提供更多细节的Ivo。


五年后,我试图安装只有egg形式的供应商代码,但是Python 2.7.15 pip 18.1却出现了“无效要求”的错误。这篇文章帮了我大忙。谢谢! - martiangoblin

7

使用Python的wheel包生成一个wheel文件,从命令行中执行以下操作:

wheel convert <path-to-egg>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接