Skip to content

Commit 4fcfcfa

Browse files
committed
Add :pypi: extlinks alias and convert inline PyPI URLs
Closes #1370. Adds a ``pypi`` entry to the ``extlinks`` dict in source/conf.py so RST files can use ``:pypi:`name``` instead of hard-coded ``pypi.org/project/name`` URLs. The role renders the project name as link text and points at ``https://pypi.org/project/<name>/``. Converts ten existing inline links where the visible text already matched the project name, so rendered output is preserved: - discussions/deploying-python-applications.rst: Pynsist, py2exe, py2app, pex - overview.rst: lxml, numpy, Pillow, pynsist - key_projects.rst: cmake (scikit-build), ninja, cmake (scikit-build-core) Deliberately left alone for this PR: - Named reference targets (``.. _name: URL``) — converting requires edits at every reuse site; can be done as a follow-up if wanted. - Inline links whose visible text differs from the project name (e.g. ``PyPI <…/bandersnatch>`` in key_projects.rst, ``PIL distribution`` in overview.rst) — converting would change the rendered prose. - ``six`` and ``modernize`` in supporting-multiple-python-versions.rst — both are also reused later as ``six_`` / ``modernize_`` named references, so the inline form cannot be replaced in isolation. - Version-pinned or anchor-bearing URLs (e.g. ``pypi.org/project/pip/23.3.1/#files``). - Template / example URLs that are not project links (``pypi.org/project/<sampleproject>``, ``test.pypi.org/...``, ``docs.pypi.org/...``). The docs build cleanly with ``sphinx-build -W --keep-going``.
1 parent c31a69a commit 4fcfcfa

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"commit": (f"{github_repo_url}/commit/%s", "%s"),
200200
"gh": (f"{github_url}/%s", "GitHub: %s"),
201201
"user": (f"{github_sponsors_url}/%s", "@%s"),
202+
"pypi": ("https://pypi.org/project/%s/", "%s"),
202203
}
203204

204205
# -- Options for intersphinx ----------------------------------------------------------

source/discussions/deploying-python-applications.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Windows
5757
Pynsist
5858
^^^^^^^
5959

60-
`Pynsist <https://pypi.org/project/pynsist>`__ is a tool that bundles Python
60+
:pypi:`Pynsist` is a tool that bundles Python
6161
programs together with the Python-interpreter into a single installer based on
6262
NSIS. In most cases, packaging only requires the user to choose a version of
6363
the Python-interpreter and declare the dependencies of the program. The tool
@@ -88,7 +88,7 @@ Windows
8888
py2exe
8989
^^^^^^
9090

91-
`py2exe <https://pypi.org/project/py2exe/>`__ is a distutils extension which
91+
:pypi:`py2exe` is a distutils extension which
9292
allows to build standalone Windows executable programs (32-bit and 64-bit)
9393
from Python scripts. Python versions included in the official development
9494
cycle are supported (refers to `Status of Python branches`__). py2exe can
@@ -105,7 +105,7 @@ macOS
105105
py2app
106106
^^^^^^
107107

108-
`py2app <https://pypi.org/project/py2app/>`__ is a Python setuptools
108+
:pypi:`py2app` is a Python setuptools
109109
command which will allow you to make standalone macOS application
110110
bundles and plugins from Python scripts. Note that py2app MUST be used
111111
on macOS to build applications, it cannot create Mac applications on other
@@ -117,7 +117,7 @@ Unix (including Linux and macOS)
117117
pex
118118
^^^
119119

120-
`pex <https://pypi.org/project/pex/>`__ is a library for generating .pex
120+
:pypi:`pex` is a library for generating .pex
121121
(Python EXecutable) files which are executable Python environments in the
122122
spirit of virtualenvs. pex is an expansion upon the ideas outlined in :pep:`441`
123123
and makes the deployment of Python applications as simple as cp. pex files may

source/key_projects.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,11 @@ scikit-build
757757

758758
Scikit-build is a :ref:`setuptools` wrapper for CPython that builds
759759
C/C++/Fortran/Cython extensions It uses
760-
`cmake <https://pypi.org/project/cmake>`__ (available on PyPI) to provide
760+
:pypi:`cmake` (available on PyPI) to provide
761761
better support for additional compilers, build systems, cross compilation, and
762762
locating dependencies and their associated build requirements. To speed up and
763-
parallelize the build of large projects, the user can install `ninja
764-
<https://pypi.org/project/ninja>`__ (also available on PyPI).
763+
parallelize the build of large projects, the user can install
764+
:pypi:`ninja` (also available on PyPI).
765765

766766
.. _scikit-build-core:
767767

@@ -773,8 +773,8 @@ scikit-build-core
773773
`PyPI <https://pypi.org/project/scikit-build-core>`__
774774

775775
Scikit-build-core is a build backend for CPython C/C++/Fortran/Cython
776-
extensions. It enables users to write extensions with `cmake
777-
<https://pypi.org/project/cmake>`__ (available on PyPI) to provide better
776+
extensions. It enables users to write extensions with
777+
:pypi:`cmake` (available on PyPI) to provide better
778778
support for additional compilers, build systems, cross compilation, and
779779
locating dependencies and their associated build requirements. CMake/Ninja
780780
are automatically downloaded from PyPI if not available on the system.

source/overview.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ go to the :ref:`source-distribution-format` specification to learn more.
9696

9797
If you rely on any non-Python code, or non-Python packages (such as
9898
`libxml2 <https://en.wikipedia.org/wiki/Libxml2>`_ in the case of
99-
`lxml <https://pypi.org/project/lxml/>`_, or BLAS libraries in the
100-
case of `numpy <https://pypi.org/project/numpy>`_), you will need to
99+
:pypi:`lxml`, or BLAS libraries in the
100+
case of :pypi:`numpy`), you will need to
101101
use the format detailed in the next section, which also has many
102102
advantages for pure-Python libraries.
103103

104104
.. note:: Python and PyPI support multiple distributions providing
105105
different implementations of the same package. For instance the
106106
unmaintained-but-seminal `PIL distribution
107107
<https://pypi.org/project/PIL/>`_ provides the PIL package, and so
108-
does `Pillow <https://pypi.org/project/Pillow/>`_, an
108+
does :pypi:`Pillow`, an
109109
actively-maintained fork of PIL!
110110

111111
This Python packaging superpower makes it possible for Pillow to be
@@ -308,7 +308,7 @@ A selection of Python freezers:
308308
* `py2exe <http://www.py2exe.org/>`_ - Windows only
309309
* `py2app <https://py2app.readthedocs.io/en/latest/>`_ - Mac only
310310
* `osnap <https://github.com/jamesabel/osnap>`_ - Windows and Mac
311-
* `pynsist <https://pypi.org/project/pynsist/>`_ - Windows only
311+
* :pypi:`pynsist` - Windows only
312312

313313
Most of the above imply single-user deployments. For multi-component
314314
server applications, see :gh:`Chef Omnibus

0 commit comments

Comments
 (0)