[Zope-CMF] GenericSetup: upgrade step ordering with newer setuptools
Maurits van Rees
m.van.rees at zestsoftware.nl
Thu Mar 26 01:17:06 CET 2015
Hi,
Short version:
1. In January yuppie did a fix on GenericSetup trunk (r130476), which
deserves a release, as it fixes upgrade step sort order with setuptools
8 and higher. Thank you, yuppie!
2. But I just created a branch (maurits-versions-setuptools) with a
minor fix for that fix, which deserves another pair of eyes. It avoids
a warning by pkg_resources.
Long version:
Setuptools includes the pkg_resources module. This has gotten some
changes recently in light of the package version numbering scheme, PEP
440. See https://www.python.org/dev/peps/pep-0440/
The upgrades.py file in GenericSetup uses pkg_resources.parse_version to
parse source and destination of upgrade steps and of the profile
revision, so it can see if an upgrade step applies, and what the order
should be.
GenericSetup 1.7.5 orders the upgrade steps differently depending on
which setuptools version you use. Not good.
For example:
1. Create a Plone 3.3.6 site, which has an old version of GenericSetup,
but that does not matter.
2. Update the Plone version to latest 4.3.4, which has GenericSetup 1.7.5.
3. Go to the plone-upgrade page, which uses portal_setup.listUpgrades to
list the upgrades available for the core Plone profile.
4. Now there are two possibilities.
A. When you use setuptools 7 or lower, all is well. There are lots of
steps, but stripped to the essence it boils down to this:
all -> 4.0
3.3.6 -> 4.0
4.0 -> 4.1
4.1 -> 4.2
4.2 - 4.3
Apply them all and you end up on version 4.3. Good.
B. When you use setuptools 8 or higher, the upgrade step order is wrong:
3.3.6 -> 4.0
4.0 -> 4.1
4.1 -> 4.2
4.2 - 4.3
all -> 4.0
After all the steps are done, you are at profile version 4.0, instead of
4.3. The following steps need to be done a second time before arriving
at the final destination of 4.3:
4.0 -> 4.1
4.1 -> 4.2
4.2 - 4.3
Anyway, yuppie fixed this elegantly by changing normalize_version in
upgrade.py to not return pkg_resources.parse_version(version), but to
call tuple() around this parsed version. A release would be good.
All is well with that fix, except for this warning by pkg_resources:
RuntimeWarning: You have iterated over the result of
pkg_resources.parse_version. This is a legacy behavior which is
inconsistent with the new version class introduced in setuptools
8.0. In most cases, conversion to a tuple is unnecessary. For
comparison of versions, sort the Version instances directly. If you
have another use case requiring the tuple, please file a bug with
the setuptools project describing that need.
So in subversion I created a branch maurits-versions-setuptools to fix
this so it works in old and new setuptools, without this really really
verbose warning.
See
svn+ssh://svn.zope.org/repos/main/Products.GenericSetup/branches/maurits-versions-setuptools
Please have a look.
Thanks,
--
Maurits van Rees: http://maurits.vanrees.org/
Zest Software: http://zestsoftware.nl
More information about the Zope-CMF
mailing list