diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2025-09-27 12:30:34 +0200 |
|---|---|---|
| committer | Sharlatan Hellseher <sharlatanus@gmail.com> | 2026-03-03 09:32:18 +0000 |
| commit | e4cc67782eb2e68428e38973c580f371122b2f14 (patch) | |
| tree | 65be2c666a89fa9df2f94d5ae6c992c6ad85fb4f /doc | |
| parent | c87031efe8fea320716e72ec4569c44f47ff8ff9 (diff) | |
doc: Refresh python documentation.
* doc/contributing.texi: Refresh python documentation (avoid uses of
"we " and "you", remove the reference to pyproject-build-system as
experimental, and adjust the setuptools situation comments).
Merges: https://codeberg.org/guix/guix/pulls/6427
Change-Id: Idb065befc975063ad97e6bdafb724e50d6891cb5
Reviewed-by: Yan Abu Arab <yanabuarab@gmail.com>
Reviewed-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/contributing.texi | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/doc/contributing.texi b/doc/contributing.texi index eb5e7f760a1..f1ab1b56da2 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi | |||
| @@ -1514,37 +1514,30 @@ satisfied. | |||
| 1514 | @subsection Python Modules | 1514 | @subsection Python Modules |
| 1515 | 1515 | ||
| 1516 | @cindex python | 1516 | @cindex python |
| 1517 | We currently package Python 2 and Python 3, under the Scheme variable names | 1517 | The standard way to generate a package definition is to use |
| 1518 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | 1518 | @code{guix import pypi <name>}, where @var{name} is the name of the |
| 1519 | To avoid confusion and naming clashes with other programming languages, it | 1519 | Python package on @url{https://pypi.org, PyPI}, see @pxref{Invoking guix |
| 1520 | seems desirable that the name of a package for a Python module contains | 1520 | import}. Please check with @code{guix lint <package-name>} that the |
| 1521 | the word @code{python}. | 1521 | generated package is valid. |
| 1522 | 1522 | ||
| 1523 | Some modules are compatible with only one version of Python, others with | 1523 | To avoid confusion and naming clashes with other programming languages, |
| 1524 | both. If the package Foo is compiled with Python 3, we name it | 1524 | Python module packages should be prefixed with @code{python-}. |
| 1525 | @code{python-foo}. If it is compiled with Python 2, we name it | 1525 | |
| 1526 | @code{python2-foo}. Python 2 packages are being removed from the | 1526 | If a project already contains the word @code{python}, please do not |
| 1527 | distribution; please do no not submit any new Python 2 packages. | 1527 | repeat it; for instance, the module python-dateutil is packaged under |
| 1528 | 1528 | the name @code{python-dateutil}. If the project name starts with | |
| 1529 | If a project already contains the word @code{python}, we drop this; | 1529 | @code{py}, it is kept and prefixed as described above (e.g.@: |
| 1530 | for instance, the module python-dateutil is packaged under the names | 1530 | @code{python-pytz}). |
| 1531 | @code{python-dateutil} and @code{python2-dateutil}. If the project name | ||
| 1532 | starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as | ||
| 1533 | described above. | ||
| 1534 | 1531 | ||
| 1535 | @quotation Note | 1532 | @quotation Note |
| 1536 | Currently there are two different build systems for Python packages in Guix: | 1533 | The standard build system for Python packages is Guix's implementation |
| 1537 | @var{python-build-system} and @var{pyproject-build-system}. For the | 1534 | of the @url{https://peps.python.org/pep-0517/, formal Python standard} |
| 1538 | longest time, Python packages were built from an informally specified | 1535 | for specifying build requirements: @var{pyproject-build-system}. |
| 1539 | @file{setup.py} file. That worked amazingly well, considering Python's | 1536 | The @var{python-build-system} which corresponds to the way Python |
| 1540 | success, but was difficult to build tooling around. As a result, a host | 1537 | packages were built before PEP517, using the informally specified |
| 1541 | of alternative build systems emerged and the community eventually settled on a | 1538 | @file{setup.py} file, is now deprecated. @var{pyproject-build-system} |
| 1542 | @url{https://peps.python.org/pep-0517/, formal standard} for specifying build | 1539 | will eventually be deprecated and renamed into |
| 1543 | requirements. @var{pyproject-build-system} is Guix's implementation of this | 1540 | @var{python-build-system} after its removal. |
| 1544 | standard. It is considered ``experimental'' in that it does not yet support | ||
| 1545 | all the various PEP-517 @emph{build backends}, but you are encouraged to try | ||
| 1546 | it for new Python packages and report any problems. It will eventually be | ||
| 1547 | deprecated and merged into @var{python-build-system}. | ||
| 1548 | @end quotation | 1541 | @end quotation |
| 1549 | 1542 | ||
| 1550 | @subsubsection Specifying Dependencies | 1543 | @subsubsection Specifying Dependencies |
| @@ -1556,21 +1549,21 @@ package source tree, with varying degrees of accuracy: in the | |||
| 1556 | @file{requirements.txt}, or in @file{tox.ini} (the latter mostly for | 1549 | @file{requirements.txt}, or in @file{tox.ini} (the latter mostly for |
| 1557 | test dependencies). | 1550 | test dependencies). |
| 1558 | 1551 | ||
| 1559 | Your mission, when writing a recipe for a Python package, is to map | 1552 | When editing a recipe for a Python package, the goal is to map these |
| 1560 | these dependencies to the appropriate type of ``input'' (@pxref{package | 1553 | dependencies to the appropriate type of ``input'' (@pxref{package |
| 1561 | Reference, inputs}). Although the @code{pypi} importer normally does a | 1554 | Reference, inputs}). Although the @code{pypi} importer normally does a |
| 1562 | good job (@pxref{Invoking guix import}), you may want to check the | 1555 | good job (@pxref{Invoking guix import}), please verify the following |
| 1563 | following check list to determine which dependency goes where. | 1556 | check list to determine which dependency goes where. |
| 1564 | 1557 | ||
| 1565 | @itemize | 1558 | @itemize |
| 1566 | 1559 | ||
| 1567 | @item | 1560 | @item |
| 1568 | We currently package Python with @code{setuptools} and @code{pip} | 1561 | Python is packaged @emph{without} @code{setuptools} and @code{pip} |
| 1569 | installed per default. This is about to change, and users are encouraged | 1562 | installed per default. @code{python-toolchain} provides a build |
| 1570 | to use @code{python-toolchain} if they want a build environment for Python. | 1563 | environment for Python. |
| 1571 | 1564 | ||
| 1572 | @command{guix lint} will warn if @code{setuptools} or @code{pip} are | 1565 | @command{guix lint} will warn if @code{pip} or other unneeded |
| 1573 | added as native-inputs because they are generally not necessary. | 1566 | native-inputs are added. |
| 1574 | 1567 | ||
| 1575 | @item | 1568 | @item |
| 1576 | Python dependencies required at run time go into | 1569 | Python dependencies required at run time go into |
| @@ -1585,9 +1578,9 @@ Python packages required only at build time---e.g., those listed under | |||
| 1585 | for testing---e.g., those in @code{tests_require} or @file{tox.ini}---go into | 1578 | for testing---e.g., those in @code{tests_require} or @file{tox.ini}---go into |
| 1586 | @code{native-inputs}. The rationale is that (1) they do not need to be | 1579 | @code{native-inputs}. The rationale is that (1) they do not need to be |
| 1587 | propagated because they are not needed at run time, and (2) in a | 1580 | propagated because they are not needed at run time, and (2) in a |
| 1588 | cross-compilation context, it's the ``native'' input that we'd want. | 1581 | cross-compilation context, it's the target ``native'' input. |
| 1589 | 1582 | ||
| 1590 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test | 1583 | Examples are the @code{pytest}, @code{mock}, and @code{stestr} test |
| 1591 | frameworks. Of course if any of these packages is also required at | 1584 | frameworks. Of course if any of these packages is also required at |
| 1592 | run-time, it needs to go to @code{propagated-inputs}. | 1585 | run-time, it needs to go to @code{propagated-inputs}. |
| 1593 | 1586 | ||
