Skip to content

Commit 2a3a40d

Browse files
authored
Merge pull request #903 from henryiii/henryiii/chore/depy2
Reduce Python 2 Universal wheels discussion
2 parents 0779498 + d37a7d2 commit 2a3a40d

2 files changed

Lines changed: 18 additions & 48 deletions

File tree

source/guides/distributing-packages-using-setuptools.rst

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -767,56 +767,32 @@ package <Built Distribution>` that can be installed without needing to go
767767
through the "build" process. Installing wheels is substantially faster for the
768768
end user than installing from a source distribution.
769769

770-
If your project is pure Python (i.e. contains no compiled extensions) and
771-
natively supports both Python 2 and 3, then you'll be creating what's called a
772-
:ref:`*Universal Wheel* (see section below) <Universal Wheels>`.
773-
774-
If your project is pure Python but does not natively support both Python 2 and
775-
3, then you'll be creating a :ref:`"Pure Python Wheel" (see section below) <Pure
776-
Python Wheels>`.
770+
If your project is pure Python then you'll be creating a
771+
:ref:`"Pure Python Wheel" (see section below) <Pure Python Wheels>`.
777772

778773
If your project contains compiled extensions, then you'll be creating what's
779774
called a :ref:`*Platform Wheel* (see section below) <Platform Wheels>`.
780775

776+
.. note:: If your project also supports Python 2 _and_ contains no C extensions,
777+
then you should create what's called a *Universal Wheel* by adding the
778+
following to your :file:`setup.cfg` file:
781779

782-
.. _`Universal Wheels`:
783-
784-
Universal Wheels
785-
~~~~~~~~~~~~~~~~
786-
787-
*Universal Wheels* are wheels that are pure Python (i.e. contain no compiled
788-
extensions) and support Python 2 and 3. This is a wheel that can be installed
789-
anywhere by :ref:`pip`.
790-
791-
You should have the following setting in :file:`setup.cfg`:
792-
793-
.. code-block:: text
794-
795-
[bdist_wheel]
796-
universal=1
797-
798-
Only use this setting if both are true:
799-
800-
1. Your project runs on Python 2 and 3 with no changes (i.e. it does not
801-
require 2to3).
802-
2. Your project does not have any C extensions.
780+
.. code-block:: text
803781
804-
Beware that there are not currently any checks to warn if you use the
805-
setting inappropriately.
782+
[bdist_wheel]
783+
universal=1
806784
807-
If your project has optional C extensions, it is recommended not to publish a
808-
universal wheel, because pip will prefer the wheel over a source installation,
809-
and prevent the possibility of building the extension.
785+
Only use this setting if your project does not have any C extesions _and_
786+
supports Python 2 and 3.
810787

811788

812789
.. _`Pure Python Wheels`:
813790

814791
Pure Python Wheels
815792
~~~~~~~~~~~~~~~~~~
816793

817-
*Pure Python Wheels* that are not "universal" are wheels that are pure Python
818-
(i.e. contain no compiled extensions), but don't natively support both Python 2
819-
and 3.
794+
*Pure Python Wheels* contain no compiled extensions, and therefore only require a
795+
single Python wheel.
820796

821797
To build the wheel:
822798

@@ -832,18 +808,12 @@ To build the wheel:
832808
833809
py -m build --wheel
834810
835-
The ``wheel`` package will detect that the code is pure Python, and build a wheel
836-
that's named such that it's usable on any Python installation with the same
837-
major version (Python 2 or Python 3) as the version you used to build the
838-
wheel. For details on the naming of wheel files, see :pep:`425`.
839-
840-
If your code supports both Python 2 and 3, but with different code (e.g., you
841-
use `"2to3" <https://docs.python.org/2/library/2to3.html>`_) you can run
842-
the build twice, once with Python 2 and once with Python 3. This
843-
will produce wheels for each version.
811+
The ``wheel`` package will detect that the code is pure Python, and build a
812+
wheel that's named such that it's usable on any Python 3 installation. For
813+
details on the naming of wheel files, see :pep:`425`.
844814

845815
If you run ``build`` without ``--wheel`` or ``--sdist``, it will build both
846-
files for you; this is useful if you don't need multiple wheels.
816+
files for you; this is useful when you don't need multiple wheels.
847817

848818
.. _`Platform Wheels`:
849819

source/guides/dropping-older-python-versions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ compatible with both Python 2 and Python 3, produce :term:`wheels
3030
<Wheel>` that have a ``py2.py3`` tag in their names. When dropping
3131
support for Python 2, it is important not to forget to change this tag
3232
to just ``py3``. It is often configured within :file:`setup.cfg` under
33-
the ``[bdist_wheel]`` section by setting ``universal = 1`` :ref:`if they
34-
use setuptools <Universal Wheels>`.
33+
the ``[bdist_wheel]`` section by setting ``universal = 1`` if they
34+
use setuptools.
3535

3636
If you use this method, either remove this option or section, or
3737
explicitly set ``universal`` to ``0``:

0 commit comments

Comments
 (0)