Project:Python/Virtuals

From Gentoo Wiki
Jump to:navigation Jump to:search

This page describes the virtual packages introduced by the Python team.

Virtual packages for backports

Those virtual packages are used to reference the Python modules which are available in newer versions of Python and that were backported to older versions of Python using external packages.

Transparent vs. non-transparent

There are two classes of backport packages: transparent and non-transparent. Transparent backports install missing modules using the same names, therefore making code written for newer versions of Python work without modification. Non-transparent backports use different module names, therefore the code using them has to explicitly support them.

For transparent backports, the packages can safely depend on the virtuals to support old Python implementations. However, if they no longer support an old implementation (even with the backports installed), the dependency should be removed altogether.

For non-transparent backports, the support for backport in the package has to be evaluated. If a package depends on a backport module unconditionally (i.e. can't work without it even on newer Python versions), it needs to depend on the backport directly. The virtual is a suitable dependency only if the backport (or the original package) is used as a fallback, and therefore the package can work without the backport on newer Python versions.

How to use the table?

  1. If transparent? is not yes, and your package always imports the module listed there, explicitly depend on the package providing that module.
  2. If transparent? is yes or your package has fallback from package to module listed in transparent?:
    1. If all Python implementations supported by your package are marked as no in relevant implementations, do not add any dependency at all (built-in module will always be used).
    2. Otherwise, depend on the virtual.

Table

Virtual Package Relevant implementations Transparent? Notes
2.7 3.4 3.5 3.6 pypy pypy3
virtual/python-backports_abc collections.abc Yes No No No Yes No backports_abc package built-in since 3.3
virtual/python-cffi cffi Yes Yes Yes Yes No No Yes built-in in PyPy
virtual/python-enum34 enum Yes No No No Yes No Yes built-in since 3.4
virtual/python-funcsigs - 0 inspect.Signature Yes No No No Yes No funcsigs module built-in since 3.3
virtual/python-funcsigs - 1 inspect.Signature Yes Yes Yes No Yes No funcsigs module built-in since 3.6 (revised version)
virtual/python-futures concurrent.futures Yes No No No Yes No Yes built-in since 3.2
virtual/python-greenlet greenlet Yes Yes Yes Yes No No Yes built-in in PyPy
virtual/python-ipaddress ipaddress Yes No No No Yes No Yes built-in since 3.3
virtual/python-pathlib pathlib Yes No No No Yes No Yes built-in since 3.4
virtual/python-singledispatch functools.singledispatch Yes No No No Yes No singledispatch module built-in since 3.4
virtual/python-typing typing Yes Yes No No Yes No Yes built-in since 3.5
virtual/python-unittest-mock unittest.mock Yes No No No Yes No mock module built-in since 3.4