-
-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Description
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 theProducts
namespace. - Support for non-native namespaces is slowly being removed from
pip
andsetuptools
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 newersetuptools
orpip
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, allplone.*
packages could still use the oldpkg_resources
-style namespaces.
Proposal & Implementation
- In Plone 7.0, all repositories in the GitHub
plone
organisation that are used by thePlone
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
, not3.0.x
. - Remove
__init__.py
from the namespace packages. InProducts.CMFPlone
we would removeProducts/__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
, andtests
directories. There are multiple ways to do this, but I propose we use asrc-layout
as this is supposed to make everything automatic. For example moveProducts
tosrc/Products
. See discussion here. This is optional, but seems best. It avoids problems like this when movingzest.releaser
over 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}
. - It is fine to still have a
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. - 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).
- 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
- 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.*
, includingplone.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
andborg.localrole
.
- First get a Zope 6 alpha release with all those packages moved to native namespaces. This includes the
- 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, andz3c.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:
- Similar Zope issue: Switch to PEP 420 (Implicit namespace packages) zopefoundation/meta#194
- The Python Packaging Guide:
- packaging namespace packages
- src-layout versus flat-layout
- Is
setup.py
deprecated? Short answer: no.
- Setuptools:
- 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
(orcross_pkg_resources_pep420
but that is basically duplicate data). The takeaway from that table, is that currently you can install a pep420 (native) and apkg_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.
gforcada and erral
Metadata
Metadata
Assignees
Type
Projects
Status
Todo