@@ -717,6 +717,20 @@ To have your project installable from a :term:`Package Index` like :term:`PyPI
717717<Distribution Package> ` (aka ":term: `Package <Distribution Package> `") for your
718718project.
719719
720+ Before you can build wheels and sdists for your project, you'll need to install the
721+ ``build `` package:
722+
723+ .. tab :: Unix/macOS
724+
725+ .. code-block :: bash
726+
727+ python3 -m pip install build
728+
729+ .. tab :: Windows
730+
731+ .. code-block :: bash
732+
733+ py -m pip install build
720734
721735
722736 Source distributions
@@ -725,15 +739,24 @@ Source distributions
725739Minimally, you should create a :term: `Source Distribution <Source Distribution (or
726740"sdist")> `:
727741
728- ::
742+ .. tab :: Unix/macOS
743+
744+ .. code-block :: bash
745+
746+ python3 -m build --sdist
747+
748+ .. tab :: Windows
749+
750+ .. code-block :: bash
729751
730- python setup. py sdist
752+ py -m build -- sdist
731753
732754
733755 A "source distribution" is unbuilt (i.e. it's not a :term: `Built
734756Distribution `), and requires a build step when installed by pip. Even if the
735757distribution is pure Python (i.e. contains no extensions), it still involves a
736- build step to build out the installation metadata from :file: `setup.py `.
758+ build step to build out the installation metadata from :file: `setup.py ` and/or
759+ :file: `setup.cfg `.
737760
738761
739762Wheels
@@ -755,20 +778,6 @@ Python Wheels>`.
755778If your project contains compiled extensions, then you'll be creating what's
756779called a :ref: `*Platform Wheel* (see section below) <Platform Wheels >`.
757780
758- Before you can build wheels for your project, you'll need to install the
759- ``wheel `` package:
760-
761- .. tab :: Unix/macOS
762-
763- .. code-block :: bash
764-
765- python3 -m pip install wheel
766-
767- .. tab :: Windows
768-
769- .. code-block :: bash
770-
771- py -m pip install wheel
772781
773782.. _`Universal Wheels` :
774783
@@ -779,35 +788,21 @@ Universal Wheels
779788extensions) and support Python 2 and 3. This is a wheel that can be installed
780789anywhere by :ref: `pip `.
781790
782- To build the wheel:
783-
784- .. tab :: Unix/macOS
785-
786- .. code-block :: bash
787-
788- python3 setup.py bdist_wheel --universal
789-
790- .. tab :: Windows
791-
792- .. code-block :: bash
793-
794- py setup.py bdist_wheel --universal
795-
796- You can also permanently set the ``--universal `` flag in :file: `setup.cfg `:
791+ You should have the following setting in :file: `setup.cfg `:
797792
798793.. code-block :: text
799794
800795 [bdist_wheel]
801796 universal=1
802797
803- Only use the `` --universal `` setting, if:
798+ Only use this setting if both are true :
804799
8058001. Your project runs on Python 2 and 3 with no changes (i.e. it does not
806801 require 2to3).
8078022. Your project does not have any C extensions.
808803
809- Beware that `` bdist_wheel `` does not currently have any checks to warn if you
810- use the setting inappropriately.
804+ Beware that there are not currently any checks to warn if you use the
805+ setting inappropriately.
811806
812807If your project has optional C extensions, it is recommended not to publish a
813808universal wheel, because pip will prefer the wheel over a source installation,
@@ -829,25 +824,26 @@ To build the wheel:
829824
830825 .. code-block :: bash
831826
832- python3 setup.py bdist_wheel
827+ python -m build --wheel
833828
834829 .. tab :: Windows
835830
836831 .. code-block :: bash
837832
838- py setup.py bdist_wheel
833+ py -m build --wheel
839834
840- `` bdist_wheel `` will detect that the code is pure Python, and build a wheel
835+ The `` wheel `` package ill detect that the code is pure Python, and build a wheel
841836that's named such that it's usable on any Python installation with the same
842837major version (Python 2 or Python 3) as the version you used to build the
843838wheel. For details on the naming of wheel files, see :pep: `425 `.
844839
845840If your code supports both Python 2 and 3, but with different code (e.g., you
846841use `"2to3" <https://docs.python.org/2/library/2to3.html >`_) you can run
847- `` setup.py bdist_wheel `` twice, once with Python 2 and once with Python 3. This
842+ the build twice, once with Python 2 and once with Python 3. This
848843will produce wheels for each version.
849844
850-
845+ 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.
851847
852848.. _`Platform Wheels` :
853849
@@ -863,23 +859,23 @@ To build the wheel:
863859
864860 .. code-block :: bash
865861
866- python3 setup.py bdist_wheel
862+ python3 -m build --wheel
867863
868864 .. tab :: Windows
869865
870866 .. code-block :: bash
871867
872- py setup.py bdist_wheel
868+ py -m build --wheel
873869
874870
875- :command: ` bdist_wheel ` will detect that the code is not pure Python, and build
871+ The `` wheel `` package will detect that the code is not pure Python, and build
876872a wheel that's named such that it's only usable on the platform that it was
877873built on. For details on the naming of wheel files, see :pep: `425 `.
878874
879875.. note ::
880876
881877 :term: `PyPI <Python Package Index (PyPI)> ` currently supports uploads of
882- platform wheels for Windows, macOS, and the multi-distro ``manylinux1 `` ABI.
878+ platform wheels for Windows, macOS, and the multi-distro ``manylinux* `` ABI.
883879 Details of the latter are defined in :pep: `513 `.
884880
885881
0 commit comments