Skip to content

Commit 2f750a4

Browse files
committed
Merge branch 'main' into musllinux
2 parents 74e6ac8 + 045d09a commit 2f750a4

38 files changed

+481
-504
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test translations
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- '**.po'
8+
branches:
9+
- translation/source
10+
push:
11+
paths:
12+
- '**.po'
13+
branches:
14+
- translation/source
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
21+
cancel-in-progress: true
22+
23+
env:
24+
I18N_BRANCH: translation/source
25+
26+
jobs:
27+
matrix:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
languages: ${{ steps.languages.outputs.languages }}
31+
32+
steps:
33+
- name: Grab the repo src
34+
uses: actions/checkout@v4
35+
with:
36+
ref: ${{ env.I18N_BRANCH }}
37+
38+
- name: List languages
39+
id: languages
40+
working-directory: locales
41+
run: |
42+
list=$(find * -maxdepth 0 -type d | jq -nRc '[inputs]')
43+
echo "languages=$list" >> $GITHUB_OUTPUT
44+
45+
46+
test-translation:
47+
runs-on: ubuntu-latest
48+
needs: matrix
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
language: ${{fromJson(needs.matrix.outputs.languages)}}
53+
54+
steps:
55+
- name: Grab the repo src
56+
uses: actions/checkout@v4
57+
with:
58+
ref: ${{ env.I18N_BRANCH }}
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: >-
64+
3.10
65+
66+
- name: Install Python tooling
67+
run: python -m pip install --upgrade nox virtualenv sphinx-lint
68+
69+
- name: Build translated docs in ${{ matrix.language }}
70+
run: nox -s build -- -q -D language=${{ matrix.language }}
71+
72+
- name: Lint translation file
73+
run: sphinx-lint locales/${{ matrix.language }}/LC_MESSAGES/messages.po

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ jobs:
4747
# This job does nothing and is only used for the branch protection
4848
# or multi-stage CI jobs, like making sure that all tests pass before
4949
# a publishing job is started.
50-
if: always()
50+
if: >-
51+
github.repository_owner == 'pypa'
52+
|| github.event_name != 'schedule'
5153
5254
needs:
5355
- build

.github/workflows/translation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
18+
if: github.repository_owner == 'pypa'
1819

1920
steps:
2021
- name: Grab the repo src
@@ -65,6 +66,7 @@ jobs:
6566
run: |
6667
git_hash=$(git rev-parse --short "${GITHUB_SHA}")
6768
git add --force locales/messages.pot
69+
git diff-index --quiet HEAD || \
6870
git commit \
6971
-m "Update messages.pot as of version ${git_hash}" \
7072
locales/messages.pot

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
- id: rst-inline-touching-normal
3535

3636
- repo: https://github.com/astral-sh/ruff-pre-commit
37-
rev: v0.1.6
37+
rev: v0.1.9
3838
hooks:
3939
- id: ruff
4040
- id: ruff-format

source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
# https://github.com/pypa/packaging.python.org/pull/1308#issuecomment-1775347690
109109
"https://www.breezy-vcs.org/*",
110110
]
111+
linkcheck_retries = 5
111112

112113
# -- Options for extlinks ----------------------------------------------------------
113114
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html#configuration
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
.. _distribution-package-vs-import-package:
2+
3+
=======================================
4+
Distribution package vs. import package
5+
=======================================
6+
7+
A number of different concepts are commonly referred to by the word
8+
"package". This page clarifies the differences between two distinct but
9+
related meanings in Python packaging, "distribution package" and "import
10+
package".
11+
12+
What's a distribution package?
13+
==============================
14+
15+
A distribution package is a piece of software that you can install.
16+
Most of the time, this is synonymous with "project". When you type ``pip
17+
install pkg``, or when you write ``dependencies = ["pkg"]`` in your
18+
``pyproject.toml``, ``pkg`` is the name of a distribution package. When
19+
you search or browse the PyPI_, the most widely known centralized source for
20+
installing Python libraries and tools, what you see is a list of distribution
21+
packages. Alternatively, the term "distribution package" can be used to
22+
refer to a specific file that contains a certain version of a project.
23+
24+
Note that in the Linux world, a "distribution package",
25+
most commonly abbreviated as "distro package" or just "package",
26+
is something provided by the system package manager of the `Linux distribution <distro_>`_,
27+
which is a different meaning.
28+
29+
30+
What's an import package?
31+
=========================
32+
33+
An import package is a Python module. Thus, when you write ``import
34+
pkg`` or ``from pkg import func`` in your Python code, ``pkg`` is the
35+
name of an import package. More precisely, import packages are special
36+
Python modules that can contain submodules. For example, the ``numpy``
37+
package contains modules like ``numpy.linalg`` and
38+
``numpy.fft``. Usually, an import package is a directory on the file
39+
system, containing modules as ``.py`` files and subpackages as
40+
subdirectories.
41+
42+
You can use an import package as soon as you have installed a distribution
43+
package that provides it.
44+
45+
46+
What are the links between distribution packages and import packages?
47+
=====================================================================
48+
49+
Most of the time, a distribution package provides one single import
50+
package (or non-package module), with a matching name. For example,
51+
``pip install numpy`` lets you ``import numpy``.
52+
53+
However, this is only a convention. PyPI and other package indices *do not
54+
enforce any relationship* between the name of a distribution package and the
55+
import packages it provides. (A consequence of this is that you cannot blindly
56+
install the PyPI package ``foo`` if you see ``import foo``; this may install an
57+
unintended, and potentially even malicious package.)
58+
59+
A distribution package could provide an import package with a different
60+
name. An example of this is the popular Pillow_ library for image
61+
processing. Its distribution package name is ``Pillow``, but it provides
62+
the import package ``PIL``. This is for historical reasons: Pillow
63+
started as a fork of the PIL library, thus it kept the import name
64+
``PIL`` so that existing PIL users could switch to Pillow with little
65+
effort. More generally, a fork of an existing library is a common reason
66+
for differing names between the distribution package and the import
67+
package.
68+
69+
On a given package index (like PyPI), distribution package names must be
70+
unique. On the other hand, import packages have no such requirement.
71+
Import packages with the same name can be provided by several
72+
distribution packages. Again, forks are a common reason for this.
73+
74+
Conversely, a distribution package can provide several import packages,
75+
although this is less common. An example is the attrs_ distribution
76+
package, which provides both an ``attrs`` import package with a newer
77+
API, and an ``attr`` import package with an older but supported API.
78+
79+
80+
How do distribution package names and import package names compare?
81+
===================================================================
82+
83+
Import packages should have valid Python identifiers as their name (the
84+
:ref:`exact rules <python:identifiers>` are found in the Python
85+
documentation) [#non-identifier-mod-name]_. In particular, they use underscores ``_`` as word
86+
separator and they are case-sensitive.
87+
88+
On the other hand, distribution packages can use hyphens ``-`` or
89+
underscores ``_``. They can also contain dots ``.``, which is sometimes
90+
used for packaging a subpackage of a :ref:`namespace package
91+
<packaging-namespace-packages>`. For most purposes, they are insensitive
92+
to case and to ``-`` vs. ``_`` differences, e.g., ``pip install
93+
Awesome_Package`` is the same as ``pip install awesome-package`` (the
94+
precise rules are given in the :ref:`name normalization specification
95+
<name-normalization>`).
96+
97+
98+
99+
---------------------------
100+
101+
.. [#non-identifier-mod-name] Although it is technically possible
102+
to import packages/modules that do not have a valid Python identifier as
103+
their name, using :doc:`importlib <python:library/importlib>`,
104+
this is vanishingly rare and strongly discouraged.
105+
106+
107+
.. _distro: https://en.wikipedia.org/wiki/Linux_distribution
108+
.. _PyPI: https://pypi.org
109+
.. _Pillow: https://pypi.org/project/Pillow
110+
.. _attrs: https://pypi.org/project/attrs

source/discussions/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ specific topic. If you're just trying to get stuff done, see
1212
pip-vs-easy-install
1313
install-requires-vs-requirements
1414
wheel-vs-egg
15+
distribution-package-vs-import-package
1516
src-layout-vs-flat-layout
1617
setup-py-deprecated

source/discussions/setup-py-deprecated.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for packaging Python projects.
1212
And :file:`setup.py` is a valid configuration file for :ref:`setuptools`
1313
that happens to be written in Python, instead of in *TOML* for example
1414
(a similar practice is used by other tools
15-
like *nox* and its :file:`nox.py` configuration file,
15+
like *nox* and its :file:`noxfile.py` configuration file,
1616
or *pytest* and :file:`conftest.py`).
1717

1818
However, ``python setup.py`` and the use of :file:`setup.py`

source/glossary.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ Glossary
6767
:term:`Import Package` (which is also commonly called a "package") or
6868
another kind of distribution (e.g. a Linux distribution or the Python
6969
language distribution), which are often referred to with the single term
70-
"distribution".
70+
"distribution". See :ref:`distribution-package-vs-import-package`
71+
for a breakdown of the differences.
7172

7273
Egg
7374

@@ -103,7 +104,8 @@ Glossary
103104
An import package is more commonly referred to with the single word
104105
"package", but this guide will use the expanded term when more clarity
105106
is needed to prevent confusion with a :term:`Distribution Package` which
106-
is also commonly called a "package".
107+
is also commonly called a "package". See :ref:`distribution-package-vs-import-package`
108+
for a breakdown of the differences.
107109

108110
Module
109111

@@ -207,10 +209,8 @@ Glossary
207209
Requirement Specifier
208210

209211
A format used by :ref:`pip` to install packages from a :term:`Package
210-
Index`. For an EBNF diagram of the format, see the
211-
`pkg_resources.Requirement
212-
<https://setuptools.readthedocs.io/en/latest/pkg_resources.html#requirement-objects>`_
213-
entry in the :ref:`setuptools` docs. For example, "foo>=1.3" is a
212+
Index`. For an EBNF diagram of the format, see :ref:`dependency-specifiers`.
213+
For example, "foo>=1.3" is a
214214
requirement specifier, where "foo" is the project name, and the ">=1.3"
215215
portion is the :term:`Version Specifier`
216216

source/guides/analyzing-pypi-package-downloads.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PyPI does not display download statistics for a number of reasons: [#]_
3232
doesn't mean it's good; Similarly just because a project hasn't been
3333
downloaded a lot doesn't mean it's bad!
3434

35-
In short, because it's value is low for various reasons, and the tradeoffs
35+
In short, because its value is low for various reasons, and the tradeoffs
3636
required to make it work are high, it has been not an effective use of
3737
limited resources.
3838

0 commit comments

Comments
 (0)