Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def fix_notfound_links(app, doctree, docname):

# Internal redirects, made relative for the current builder (html or dirhtml)
internal_redirects = {
"guides/dropping-older-python-versions": "guides/writing-pyproject-toml",
"guides/single-sourcing-package-version": "discussions/single-source-version",
}

Expand Down
2 changes: 1 addition & 1 deletion source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Discussions

Discussions are focused on understanding and information. These explore a
specific topic without a specific goal in mind. :doc:`example discussion-style
document <discussions/install-requires-vs-requirements>`.
document <discussions/src-layout-vs-flat-layout>`.

Specifications
--------------
Expand Down
139 changes: 0 additions & 139 deletions source/discussions/deploying-python-applications.rst

This file was deleted.

3 changes: 0 additions & 3 deletions source/discussions/downstream-packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
Supporting downstream packaging
===============================

:Page Status: Draft
:Last Reviewed: 2025-?

While PyPI and the Python packaging tools such as :ref:`pip` are the primary
means of distributing Python packages, they are also often made available as part
of other packaging ecosystems. These repackaging efforts are collectively called
Expand Down
3 changes: 0 additions & 3 deletions source/discussions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ specific topic. If you're just trying to get stuff done, see
:maxdepth: 1

versioning
deploying-python-applications
install-requires-vs-requirements
distribution-package-vs-import-package
package-formats
src-layout-vs-flat-layout
setup-py-deprecated
single-source-version
downstream-packaging
91 changes: 11 additions & 80 deletions source/discussions/install-requires-vs-requirements.rst
Original file line number Diff line number Diff line change
@@ -1,89 +1,20 @@
:orphan:

.. _`install_requires vs requirements files`:

======================================
install_requires vs requirements files
======================================

For documentation on these topics, see:

install_requires
----------------

``install_requires`` is a :ref:`setuptools` :file:`setup.py` keyword that
should be used to specify what a project **minimally** needs to run correctly.
When the project is installed by :ref:`pip`, this is the specification that is
used to install its dependencies.

For example, if the project requires A and B, your ``install_requires`` would be
like so:

::

install_requires=[
'A',
'B'
]

Additionally, it's best practice to indicate any known lower or upper bounds.

For example, it may be known, that your project requires at least v1 of 'A', and
v2 of 'B', so it would be like so:

::

install_requires=[
'A>=1',
'B>=2'
]

It may also be known that project 'A' introduced a change in its v2
that breaks the compatibility of your project with v2 of 'A' and later,
so it makes sense to not allow v2:

::

install_requires=[
'A>=1,<2',
'B>=2'
]

It is not considered best practice to use ``install_requires`` to pin
dependencies to specific versions, or to specify sub-dependencies
(i.e. dependencies of your dependencies). This is overly-restrictive, and
prevents the user from gaining the benefit of dependency upgrades.

Lastly, it's important to understand that ``install_requires`` is a listing of
"Abstract" requirements, i.e just names and version restrictions that don't
determine where the dependencies will be fulfilled from (i.e. from what
index or source). The where (i.e. how they are to be made "Concrete") is to
be determined at install time using :ref:`pip` options. [1]_


Requirements files
------------------

:ref:`Requirements Files <pip:Requirements Files>` described most simply, are
just a list of :ref:`pip:pip install` arguments placed into a file.

Whereas ``install_requires`` defines the dependencies for a single project,
:ref:`Requirements Files <pip:Requirements Files>` are often used to define
the requirements for a complete Python environment.

Whereas ``install_requires`` requirements are minimal, requirements files
often contain an exhaustive listing of pinned versions for the purpose of
achieving :ref:`repeatable installations <pip:Repeatability>` of a complete
environment.

Whereas ``install_requires`` requirements are "Abstract", i.e. not associated
with any particular index, requirements files often contain pip
options like ``--index-url`` or ``--find-links`` to make requirements
"Concrete", i.e. associated with a particular index or directory of
packages. [1]_

Whereas ``install_requires`` metadata is automatically analyzed by pip during an
install, requirements files are not, and only are used when a user specifically
installs them using ``python -m pip install -r``.
* ``install_requires``: `Declaring required dependency`_ in the setuptools documentation.
* :file:`requirements.txt`: `Requirements File Format`_ in the pip documentation.

----
This page previously explained abstract versus concrete requirements. For an
explanation of that distinction, see `setup.py vs requirements.txt`_ by Donald
Stufft.

.. [1] For more on "Abstract" vs "Concrete" requirements, see
https://caremad.io/posts/2013/07/setup-vs-requirement/.
.. _Declaring required dependency: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#declaring-required-dependency
.. _Requirements File Format: https://pip.pypa.io/en/stable/reference/requirements-file-format/
.. _setup.py vs requirements.txt: https://caremad.io/posts/2013/07/setup-vs-requirement/
48 changes: 0 additions & 48 deletions source/discussions/package-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,47 +131,6 @@ All technical details on the wheel format can be found in the :ref:`wheel
specification <binary-distribution-format>`.


.. _egg-format:
.. _`Wheel vs Egg`:

What about eggs?
================

"Egg" is an old package format that has been replaced with the wheel format. It
should not be used anymore. Since August 2023, PyPI `rejects egg uploads
<pypi-eggs-deprecation_>`_.

Here's a breakdown of the important differences between wheel and egg.

* The egg format was introduced by :ref:`setuptools` in 2004, whereas the wheel
format was introduced by :pep:`427` in 2012.

* Wheel has an :doc:`official standard specification
</specifications/binary-distribution-format>`. Egg did not.

* Wheel is a :term:`distribution <Distribution Package>` format, i.e a packaging
format. [#wheel-importable]_ 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. Therefore, when the distribution
only contains Python files (i.e. no compiled extensions), and is compatible
with Python 2 and 3, it's possible for a wheel to be "universal", similar to
an :term:`sdist <Source Distribution (or "sdist")>`.

* Wheel uses standard :ref:`.dist-info directories
<recording-installed-packages>`. Egg used ``.egg-info``.

* Wheel has a :ref:`richer file naming convention <wheel-file-name-spec>`. A
single wheel archive can indicate its compatibility with a number of Python
language versions and implementations, ABIs, and system architectures.

* Wheel is versioned. Every wheel file contains the version of the wheel
specification and the implementation that packaged it.

* Wheel is internally organized by `sysconfig path type
<https://docs.python.org/2/library/sysconfig.html#installation-paths>`_,
therefore making it easier to convert to other formats.

--------------------------------------------------------------------------------

.. [#core-metadata-format] This format is email-based. Although this would
Expand All @@ -181,13 +140,6 @@ Here's a breakdown of the important differences between wheel and egg.
understood by the build backend, typically ``[project]`` in ``pyproject.toml``,
and translated by the build backend into ``PKG-INFO``.

.. [#wheel-importable] Circumstantially, in some cases, wheels can be used
as an importable runtime format, although :ref:`this is not officially supported
at this time <binary-distribution-format-import-wheel>`.



.. _pip-pypi: https://pypi.org/project/pip/23.3.1/#files
.. _pypi: https://pypi.org
.. _pypi-eggs-deprecation: https://blog.pypi.org/posts/2023-06-26-deprecate-egg-uploads/
.. _pypy: https://pypy.org
Loading
Loading