【问题标题】:Can I convert an egg to wheel?我可以把鸡蛋变成轮子吗?
【发布时间】:2014-03-18 08:10:53
【问题描述】:

我有一个已经构建/下载的 Python Egg,我想将其转换为 PEP 427 中记录的轮格式。
我该怎么做?

【问题讨论】:

    标签: python pip packaging egg python-wheel


    【解决方案1】:

    答案是肯定的。
    我们只需要wheel包,我们甚至不需要安装它,根据docs,我们可以直接使用它(因为.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 参数并传递egg 进行转换:

    pdobrogost@host:~$ python ./wheel-0.22.0-py2.py3-none-any.whl/wheel convert ./my-egg.egg
    

    感谢 Paul Moore 在 vi​​rtualenv 小组中提供 answer 并感谢 Ivo 在 #pip irc 频道上提供更多详细信息。

    【讨论】:

    • 大约五年后,我试图安装仅以鸡蛋形式出现的供应商代码,python 2.7.15 pip 18.1 因“无效要求”而犹豫不决。这救了我。谢谢!
    【解决方案2】:

    要从鸡蛋生成轮子,安装 Python 的 wheel 包,从命令行使用:

    wheel convert <path-to-egg>
    

    【讨论】:

      猜你喜欢
      • 2017-03-03
      • 2018-09-17
      • 2011-09-02
      • 2017-02-28
      • 2010-10-19
      • 2017-03-08
      • 2020-04-24
      • 2013-02-11
      • 1970-01-01
      相关资源
      最近更新 更多