Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
96058cc
Start a discussion on helping downstream packaging
mgorny Jan 27, 2025
b4cb7d2
Add a section on Internet access
mgorny Jan 27, 2025
df7081c
Also suggest the option of splitting test data into separate archive
mgorny Jan 27, 2025
cff76df
Add a section on system dependencies
mgorny Jan 28, 2025
be242a8
Add a section on downstream testing
mgorny Jan 28, 2025
9f9af53
Expand on downstream testing, and add emphasis for readability
mgorny Jan 29, 2025
00f39e5
Reorganize into why/how sections, and add emphasis
mgorny Jan 29, 2025
08c70e8
Elaborate a bit more on why it's good to help downstreams
mgorny Jan 29, 2025
24f552e
Correct "pytest" capitalization
mgorny Jan 29, 2025
24b0346
Apply suggestions from code review
mgorny Jan 30, 2025
16288af
Apply more suggestions from code review
mgorny Jan 30, 2025
b4c7485
Attempt addressing the remaining review comments
mgorny Jan 30, 2025
df0c91a
Add a section on stable channels
mgorny Jan 30, 2025
fc72a38
Retitle as "Supporting downstream packaging"
mgorny Jan 31, 2025
24462f4
Add a "not all-or-nothing" sentence
mgorny Jan 31, 2025
29cc38a
Add a note that downstreams can send patches to fix these issues
mgorny Jan 31, 2025
9d5fbe6
Capitalize Git, per @pawamoy
mgorny Feb 1, 2025
4d95da2
Fix inconsistent case in bullet points and remove duplicate
mgorny Feb 1, 2025
6f55709
Apply typo fixes, thanks to @pawamoy
mgorny Feb 1, 2025
548ab34
Clarify that source distribution needs only package's files
mgorny Feb 1, 2025
e925da1
Fix inconsistent whitespace between sentences
mgorny Feb 1, 2025
0eb407c
Make the point of reusing source distribution lighter
mgorny Feb 1, 2025
94743f9
Clarify the Internet part
mgorny Feb 1, 2025
704d1a5
Apply suggestions from code review
mgorny Feb 1, 2025
e596609
Remove duplicate paragraph
mgorny Feb 1, 2025
169281d
Clarify source distributions
mgorny Feb 1, 2025
bb8ac35
Add non-reproducibility argument for changing resources
mgorny Feb 1, 2025
addf891
Mention removing duplication of patches and inconsistency
mgorny Feb 2, 2025
8a3a56c
Reword installing tests to make it clearer
mgorny Feb 2, 2025
58eaf85
Give an example of "catastrophic failure"
mgorny Feb 2, 2025
76aaf79
Indicate that some distributions require building from sources
mgorny Feb 22, 2025
4f97860
Merge branch 'main' into discussion-downstream
ncoghlan Feb 26, 2025
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
Prev Previous commit
Next Next commit
Add a section on system dependencies
  • Loading branch information
mgorny committed Jan 28, 2025
commit cff76df08c13f83b5a8bb4d25192e957c516d108
70 changes: 70 additions & 0 deletions source/discussions/downstream-packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,73 @@ for a number of reasons:

Since downstreams frequently also run tests and build documentation, the above
should ideally extend to these processes as well.


.. _Support building against system dependencies:

Support building against system dependencies
--------------------------------------------
Some Python projects have non-Python dependencies, such as libraries written
in C or C++. Trying to use the system versions of these dependencies
in upstream packaging may cause a number of problems for end users:

- The published wheels require a binary-compatible version of the used library
to be present on the user's system. If the library is missing or installed
in incompatible version, the Python package may fail with errors that
are not clear to inexperienced users, or even misbehave at runtime.

- Building from source distribution requires a source-compatible version
of the dependency to be present, along with its development headers and other
auxiliary files that some systems package separately from the library itself.

- Even for an experienced user, installing a compatible dependency version
may be very hard. For example, the used Linux distribution may not provide
the required version, or some other package may require an incompatible
version.

- The linkage between the Python package and its system dependency is not
recorded by the packaging system. The next system update may upgrade
the library to a newer version that breaks binary compatibility with
the Python package, and requires user intervention to fix.

For these reasons, you may reasonable to decide to either link statically
to your dependencies, or to provide a local copies in the installed package.
You may also vendor the dependency in your source distribution. Sometimes
these dependencies are also repackaged on PyPI, and can be installed
like a regular Python packages.

However, none of these issues apply to downstream packaging, and downstreams
have good reasons to prefer dynamically linking to system dependencies.
In particular:

- Static linking and vendoring obscures the use of external dependencies,
making source auditing harder.

- Dynamic linking makes it possible to easily and quickly replace the used
libraries, which can be particularly important when they turn out to
be vulnerable or buggy.

- Using system dependencies makes the package benefit from downstream
customization that can improve the user experience on a particular platform,
without the downstream maintainers having to consistently patch
the dependencies vendored in different packages. This can include
compatibility improvements and security hardening.

- Static linking and vendoring could result in multiple different versions
of the same library being loaded in the same process (e.g. when you use two
Python packages that link to different versions of the same library).
This can cause no problems, but it could also lead to anything from subtle
bugs to catastrophic failures.

- Last but not least, static linking and vendoring results in duplication,
and may increase the use of both the disk space and memory.

A good compromise between the needs of both parties is to provide a switch
between using vendored and system dependencies. Ideally, if the package has
multiple vendored dependencies, it should provide both individual switches
for each dependency, and a general switch, for example using
a ``USE_SYSTEM_DEPS`` environment variable to control the default. If switched
on, and a particular dependency is either missing or incompatible, the build
should fail with an explanatory message, giving the packager an explicit
indication of the problem and a chance to consciously decide on the preferred
course of action.