You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move from setuptools/pkg_resources namespaces to native namespaces.
This is a breaking change that we need for Plone 6.2, because setuptools plans to drop its pkg_resources module near the end of 2025.
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 6.2, 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.1. We want to leave room for new features in Plone 6.1, 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.1.
Remove any Plone 6.1 and earlier PyPI classifiers and add the Plone 6.2 classifier.
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 6.2.0a1 that is not much different from the latest Plone 6.1, 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 6.2, to avoid complete overload.
Deliverables
For each package, the main/master branch needs to be for Plone 6.2 only. Each package needs an alpha release on PyPI.
Update on scaffolding generators to use native namespaces.
A full Plone 6.2.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. Using zc.buildout 5 will help, and also horse-with-no-namespace for pip.
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.
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.
The PyPA sample namespace packages repo has sample namespace packages for each of the three possible namespace variants. The readme has remarks on staggered migrations, including a table. Relevant to us in the table are the lines with cross_pep420_pkg_resources (or cross_pkg_resources_pep420 but that is basically duplicate data). The takeaway from that table, is that currently you can install a pep420 (native) and a pkg_resources package within the same namespace under some conditions:
both installed normally: works
both installed in editable mode: works (this surprises me a bit)
native installed in editable mode, pkg_resources normal: works
native installed normally, pkg_resources in editable mode: does NOT work.
Distributions
The list of distributions that need to be migrated to native namespace are:
Responsible Persons
Proposer: Maurits van Rees
Seconder: Gil Forcada Codinachs
Abstract
Move from
setuptools/pkg_resourcesnamespaces to native namespaces.This is a breaking change that we need for Plone 6.2, because
setuptoolsplans to drop itspkg_resourcesmodule near the end of 2025.Motivation
Use of
pkg_resourcesfromsetuptoolsis deprecated. Native namespaces have been available since Python 3.3 and are now the recommended and most easy way to define namespaces.Assumptions
Since it is best to move all packages within one namespace at the same time, we need to coordinate with Zope for the
Productsnamespace.pipandsetuptoolsand other packaging related software. Bugs may be less likely to get a fix.setuptools. There are other ways to handle packaging and distribution nowadays.pkg_resourcesnamespaces 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 newersetuptoolsorpipversion. It is best to move over all packages from a single namespace at the same time.zope.*packages have moved to non-native namespaces, allplone.*packages could still use the oldpkg_resources-style namespaces.Proposal & Implementation
ploneorganisation that are used by thePlonepackage should move to native namespaces. Others too where possible, and where we have control.collectivenamespace.3.x, not3.0.x.__init__.pyfrom the namespace packages. InProducts.CMFPlonewe would removeProducts/__init__.py.browser,profiles, andtestsdirectories. There are multiple ways to do this, but I propose we use asrc-layoutas this is supposed to make everything automatic. For example moveProductstosrc/Products. See discussion here. This is optional, but seems best. It avoids problems like this when movingzest.releaserover to using native namespaces. It will make some QA code easier, for example inplone/meta, because all code will be insrc, instead of in any of{src, plone, Products, etc}.setup.py: this PLIP is not about getting rid ofsetuptools. We must then declare setuptools as build backend inpyproject.toml, which we are already starting to do in Plone 6.1.Productsnamespace. The pure Zope community can use help from the wider Plone community in this.Productsnamespace.plone.*, includingplone.app.*.collective,plonetheme,borg,zc,z3c,repoze,five.plonetheme.barcelonetaandborg.localrole.Deliverables
collectivenamespace.Risks
zc.buildout5 will help, and alsohorse-with-no-namespaceforpip.zope.testrunnerwas already updated, andz3c.dependencycheckeras well.Participants
Links:
setup.pydeprecated? Short answer: no.pkg_resourcescross_pep420_pkg_resources(orcross_pkg_resources_pep420but that is basically duplicate data). The takeaway from that table, is that currently you can install a pep420 (native) and apkg_resourcespackage within the same namespace under some conditions:Distributions
The list of distributions that need to be migrated to native namespace are:
srclayout first) Pep 420 native namespace borg.localrole#40