Skip to content

PLIP: Switch to PEP 420 (Implicit namespace packages) #3928

@mauritsvanrees

Description

@mauritsvanrees

Responsible Persons

Proposer: Maurits van Rees

Seconder:

Abstract

Move from setuptools/pkg_resources namespaces to native namespaces.
This is a breaking change, so is for Plone 7.

Motivation

Use of pkg_resources from setuptools is deprecated. Native namespaces have been available since Python 3.3 and are now the recommended and most easy way to define namespaces.

Assumptions

  • Zope wants to make the same move.
    Since it is best to move all packages within one namespace at the same time, we need to coordinate with Zope for the Products namespace.
  • Support for non-native namespaces is slowly being removed from pip and setuptools and other packaging related software. Bugs may be less likely to get a fix.
  • We want to be less dependent on setuptools. There are other ways to handle packaging and distribution nowadays.
  • Theoretically you can combine native namespaces and pkg_resources namespaces within the same namespace, but this depends on the tools that you use, and whether you make a development checkout of a package. A combination that works today, might fail tomorrow with a newer setuptools or pip version. It is best to move over all packages from a single namespace at the same time.
  • Note that there should be no problem combining different namespace variants in different namespaces: if all zope.* packages have moved to non-native namespaces, all plone.* packages could still use the old pkg_resources-style namespaces.

Proposal & Implementation

  • In Plone 7.0, all repositories in the GitHub plone organisation that are used by the Plone package should move to native namespaces. Others too where possible, and where we have control.
  • In the upgrade guide, give add-on authors the advice to do the same. This goes especially for the collective namespace.
  • The main changes per package:
    • Make a maintenance branch for this package on Plone 6. We want to leave room for new features in Plone 6, so the branch should be something like 3.x, not 3.0.x.
    • Remove __init__.py from the namespace packages. In Products.CMFPlone we would remove Products/__init__.py.
    • Make sure all packages (directories) in the package are found, and are included when creating a distribution. This includes for example the browser, profiles, and tests directories. There are multiple ways to do this, but I propose we use a src-layout as this is supposed to make everything automatic. For example move Products to src/Products. See discussion here. This is optional, but seems best. It avoids problems like this when moving zest.releaser over to using native namespaces. It will make some QA code easier, for example in plone/meta, because all code will be in src, instead of in any of {src, plone, Products, etc}.
    • It is fine to still have a setup.py: this PLIP is not about getting rid of setuptools. We must then declare setuptools as build backend in pyproject.toml, which we are already starting to do in Plone 6.
    • Remove any Plone 6 PyPI classifiers and add the Plone 7.0 classifier (once it exists).
    • Increase the major version of the package, because this is a breaking change.
    • Make a quick alpha release on PyPI with only these changes (and any other breaking changes that may have already been added).
    • Compare the number of tests before and after: there are various ways for tests to get lost (tests directory not included in the distribution), or not be discovered (the tests directory is there, but the test runner can't find it).
  • We would have an early Plone 7.0.0a1 that is not much different from the latest Plone 6, except for the namespace implementation.
  • The order does not matter too much, but this would be one way:
    • First get a Zope 6 alpha release with all those packages moved to native namespaces. This includes the Products namespace. The pure Zope community can use help from the wider Plone community in this.
    • Do the Plone part of the Products namespace.
    • plone.*, including plone.app.*.
    • Others, like collective, plonetheme, borg, zc, z3c, repoze, five.
    • We could also start with small namespaces. We have two namespaces that only have one package in core Plone: plonetheme.barceloneta and borg.localrole.
  • If we do this during a sprint, we may need to temporarily disable Jenkins for Plone 7, to avoid complete overload.

Deliverables

  • For each package, the main/master branch needs to be for Plone 7 only. Each package needs an alpha release on PyPI.
  • A full Plone 7.0.0a1 release.
  • Documentation:
    • Document what/why/how we did this.
    • Include links to several pull requests as example.
    • Advise add-on authors to do the same for their packages, especially in the collective namespace.

Risks

  • Core Plone development will likely be broken for a while, until an entire namespace has been taken care of.
  • We may temporarily lose some tests in a package if we are not careful. We may only notice this later, and then find they have been broken in the meantime.
  • Some tooling may need updates. zope.testrunner was already updated, and z3c.dependencychecker as well.

Participants

  • Maurits van Rees, Release Manager. I will need to do a lot of releases. :-) I can do some packages too, but it would be good if others did most of them. A group of people can do a lot in a day of sprinting or on a Plone TuneUp day.

Links:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions