Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I convert an egg to wheel?

I have an already built/downloaded Python egg and I would like to convert it to the wheel format documented in PEP 427.
How can I do this?

like image 579
Piotr Dobrogost Avatar asked Feb 18 '14 13:02

Piotr Dobrogost


People also ask

What is the difference between egg and wheel?

Wheel is a distribution format, i.e a packaging format. 1 Egg was both a distribution format and a runtime installation format (if left zipped), and was designed to be importable. Wheel archives do not include . pyc files.

Are Python eggs deprecated?

There is also a third, now deprecated format: the Python 'egg'. You're very unlikely to encounter this format directly, however much of setuptools and pip's internal behaviour was influenced by this format.


1 Answers

The answer is yes.
We need only wheel package and we don't even need to install it, as according to docs, we can use it directly (due to the fact .whl files have the same format as .zip files and Python can run code in .zip files directly):

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

Now, all we have to do is to use convert argument and pass egg to be converted:

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

Thanks to Paul Moore for providing answer on virtualenv's group and to Ivo for providing more details on #pip irc channel.

like image 120
Piotr Dobrogost Avatar answered Oct 11 '22 12:10

Piotr Dobrogost