Home Explore Blog Models CI



nixpkgs

26th chunk of `doc/languages-frameworks/python.section.md`
85919d5b4616c2c93adfdda2954e34c5c93d0e282918a94700000001000009e9
* Make sure the tests are enabled using for example [`pytestCheckHook`](#using-pytestcheckhook) and, in the case of
  libraries, are passing for all interpreters. If certain tests fail they can be
  disabled individually. Try to avoid disabling the tests altogether. In any
  case, when you disable tests, leave a comment explaining not only _what_ the failure
  is but _why_ the test failure can be ignored for safe distribution with nixpkgs.
* `pythonImportsCheck` is set. This is still a good smoke test even if `pytestCheckHook` is set.
* `meta.platforms` takes the default value in many cases.
  It does not need to be set explicitly unless the package requires a specific platform.
* The file is formatted with `nixfmt-rfc-style`.
* Commit names of Python libraries must reflect that they are Python
  libraries (e.g. `python3Packages.numpy: 1.11 -> 1.12` rather than `numpy: 1.11 -> 1.12`).
  See also [`pkgs/README.md`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#commit-conventions).
* Attribute names in `python-packages.nix` as well as `pname`s should match the
  library's name on PyPI, but be normalized according to [PEP
  0503](https://www.python.org/dev/peps/pep-0503/#normalized-names). This means
  that characters should be converted to lowercase and `.` and `_` should be
  replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz).
  If necessary, `pname` has to be given a different value within `fetchPypi`.
* It's generally preferable to fetch `src` directly from the repo and not from
  PyPI. Use `fetchPypi` when there's a clear technical reason to do so.
* Packages from sources such as GitHub and GitLab that do not exist on PyPI
  should not use a name that is already used on PyPI. When possible, they should
  use the package repository name prefixed with the owner (e.g. organization) name
  and using a `-` as delimiter.
* Attribute names in `python-packages.nix` should be sorted alphanumerically to
  avoid merge conflicts and ease locating attributes.
* Non-python runtime dependencies should be added via explicit wrapping or
  patching (using e.g. `substituteInPlace`), rather than through propagation via
  `dependencies`/`propagatedBuildInputs`, to reduce clutter in `$PATH`.

This list is useful for reviewers as well as for self-checking when submitting packages.

## Package set maintenance {#python-package-set-maintenance}

The whole Python package set has a lot of packages that do not see regular
updates, because they either are a very fragile component in the Python

Title: Nixpkgs Python Contribution Guidelines: Testing, Naming, and Package Set Maintenance
Summary
This text continues the contributing guidelines for Python packages in Nixpkgs, emphasizing several best practices. It stresses the importance of enabling and passing tests across all interpreters, using `pytestCheckHook` and `pythonImportsCheck`, and providing detailed explanations if tests must be disabled. Other guidelines include using `nixfmt-rfc-style` for formatting, adhering to specific commit naming conventions for Python libraries, and normalizing attribute names (PNAME) according to PEP 0503. It also advises fetching source directly from repositories rather than PyPI when possible, using unique names for non-PyPI packages, alphanumerically sorting attributes, and managing non-Python runtime dependencies via explicit wrapping instead of propagation. The document concludes by stating these rules are for both contributors and reviewers, then transitions to discuss the maintenance of the Python package set, particularly for less frequently updated packages.