| 1 |
User Guide |
| 2 |
========== |
| 3 |
|
| 4 |
Building Wheels |
| 5 |
--------------- |
| 6 |
|
| 7 |
To build a wheel for your project:: |
| 8 |
|
| 9 |
python -m pip install build |
| 10 |
python -m build --wheel |
| 11 |
|
| 12 |
This will build any C extensions in the project and then package those and the |
| 13 |
pure Python code into a ``.whl`` file in the ``dist`` directory. |
| 14 |
|
| 15 |
If your project contains no C extensions and is expected to work on both |
| 16 |
Python 2 and 3, you will want to tell wheel to produce universal wheels by |
| 17 |
adding this to your ``setup.cfg`` file: |
| 18 |
|
| 19 |
.. code-block:: ini |
| 20 |
|
| 21 |
[bdist_wheel] |
| 22 |
universal = 1 |
| 23 |
|
| 24 |
|
| 25 |
Including license files in the generated wheel file |
| 26 |
--------------------------------------------------- |
| 27 |
|
| 28 |
Several open source licenses require the license text to be included in every |
| 29 |
distributable artifact of the project. By default, ``wheel`` conveniently |
| 30 |
includes files matching the following glob_ patterns in the ``.dist-info`` |
| 31 |
directory: |
| 32 |
|
| 33 |
* ``AUTHORS*`` |
| 34 |
* ``COPYING*`` |
| 35 |
* ``LICEN[CS]E*`` |
| 36 |
* ``NOTICE*`` |
| 37 |
|
| 38 |
This can be overridden by setting the ``license_files`` option in the |
| 39 |
``[metadata]`` section of the project's ``setup.cfg``. For example: |
| 40 |
|
| 41 |
.. code-block:: cfg |
| 42 |
|
| 43 |
[metadata] |
| 44 |
license_files = |
| 45 |
license.txt |
| 46 |
3rdparty/*.txt |
| 47 |
|
| 48 |
No matter the path, all the matching license files are written in the wheel in |
| 49 |
the ``.dist-info`` directory based on their file name only. |
| 50 |
|
| 51 |
By specifying an empty ``license_files`` option, you can disable this |
| 52 |
functionality entirely. |
| 53 |
|
| 54 |
.. note:: There used to be an option called ``license_file`` (singular). |
| 55 |
As of wheel v0.32, this option has been deprecated in favor of the more |
| 56 |
versatile ``license_files`` option. |
| 57 |
|
| 58 |
.. _glob: https://docs.python.org/library/glob.html |
| 59 |
|
| 60 |
Converting Eggs to Wheels |
| 61 |
------------------------- |
| 62 |
|
| 63 |
The wheel tool is capable of converting eggs to the wheel format. |
| 64 |
It works on both ``.egg`` files and ``.egg`` directories, and you can convert |
| 65 |
multiple eggs with a single command:: |
| 66 |
|
| 67 |
wheel convert blah-1.2.3-py2.7.egg foo-2.0b1-py3.5.egg |
| 68 |
|
| 69 |
The command supports wildcard expansion as well (via :func:`~glob.iglob`) to |
| 70 |
accommodate shells that do not do such expansion natively:: |
| 71 |
|
| 72 |
wheel convert *.egg |
| 73 |
|
| 74 |
By default, the resulting wheels are written to the current working directory. |
| 75 |
This can be changed with the ``--dest-dir`` option:: |
| 76 |
|
| 77 |
wheel convert --dest-dir /tmp blah-1.2.3-py2.7.egg |
| 78 |
|
| 79 |
Installing Wheels |
| 80 |
----------------- |
| 81 |
|
| 82 |
To install a wheel file, use pip_:: |
| 83 |
|
| 84 |
$ pip install someproject-1.5.0-py2-py3-none.whl |
| 85 |
|
| 86 |
.. _pip: https://pypi.org/project/pip/ |
| 87 |
|
| 88 |
|
| 89 |
Inspecting Wheels |
| 90 |
----------------- |
| 91 |
|
| 92 |
To inspect the metadata and contents of a wheel file without installing it, |
| 93 |
use the ``wheel info`` command:: |
| 94 |
|
| 95 |
$ wheel info someproject-1.5.0-py2-py3-none.whl |
| 96 |
|
| 97 |
This will display information about the wheel including: |
| 98 |
|
| 99 |
* Package name and version |
| 100 |
* Supported Python versions and platforms |
| 101 |
* Dependencies and other metadata |
| 102 |
* File count and total size |
| 103 |
|
| 104 |
For more detailed information including a complete file listing, use the |
| 105 |
``--verbose`` flag:: |
| 106 |
|
| 107 |
$ wheel info --verbose someproject-1.5.0-py2-py3-none.whl |
| 108 |
|
| 109 |
This is useful for: |
| 110 |
|
| 111 |
* Verifying wheel contents before installation |
| 112 |
* Debugging packaging issues |
| 113 |
* Understanding wheel structure and metadata |
| 114 |
* Checking supported platforms and Python versions |