No attribute '_finalize_feature_opts' during 20230921 update

I'm running into an error in setuptools upgrading from 5.2.7 to 5.2.14. I'm stuck.

I'm sure I'm overlooking something simple. Here we go!

Python 3.8.10

This is a simple buildout upgrade so....

# Extend the version config file
extends =
#    https://dist.plone.org/release/5.2.7/versions.cfg
     https://dist.plone.org/release/5.2.14/versions.cfg
    versions.cfg
versions = versions

(ignore versions.cfg - it's empty!)

That gets me into the "upgraded setuptools... restarting" loop most of us are aware of.... so let's upgrade buildout and setuptools manually:

requirements.txt changes:

@@ -1,3 +1,3 @@
-setuptools==42.0.2
-zc.buildout==2.13.4
-wheel==0.34.2
+setuptools==65.7.0
+zc.buildout==3.0.1
+wheel==0.38.4

./bin/pip install -r requirements.txt

good results.

Now buildout runs and starts downloading new eggs for 5.2.14, but we start erroring out:

While:
  Initializing.
  Getting section buildout.
  Initializing section buildout.
  Getting option buildout:test-eggs.
  Getting section instance.
  Initializing section instance.
  Installing recipe plone.recipe.zope2instance.
  Getting distribution for 'transaction>=2.4'.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 2250, in main
    buildout = Buildout(config_file, options,

--snip--

  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/wheel.py", line 167, in _convert_metadata
    setup_dist = setuptools.Distribution(
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/dist.py", line 475, in __init__
    _Distribution.__init__(
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/dist.py", line 898, in finalize_options
    for ep in sorted(loaded, key=by_order):
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/dist.py", line 897, in <lambda>
    loaded = map(lambda e: e.load(), filtered)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 196, in load
    return functools.reduce(getattr, attrs, module)
AttributeError: type object 'Distribution' has no attribute '_finalize_feature_opts'

In the specific problem above, it was the transaction package. It's not always there. Lately, I've seen collective.xmltestreport==2.0.2

While:
  Installing.
  Getting section test.
  Initializing section test.
  Installing recipe collective.xmltestreport.
  Getting distribution for 'collective.xmltestreport==2.0.2'.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 2252, in main
    getattr(buildout, command)(args)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 740, in install
    [self[part]['recipe'] for part in install_parts]
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 740, in <listcomp>
    [self[part]['recipe'] for part in install_parts]
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 1373, in __getitem__
    options._initialize()
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 1481, in _initialize
    self.initialize()
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 1487, in initialize
    recipe_class = _install_and_load(reqs, 'zc.buildout', entry, buildout)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/buildout.py", line 1430, in _install_and_load
    zc.buildout.easy_install.install(
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/easy_install.py", line 971, in install
    return installer.install(specs, working_set)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/easy_install.py", line 696, in install
    for dist in self._get_dist(requirement, ws):
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/easy_install.py", line 581, in _get_dist
    dists = [_move_to_eggs_dir_and_compile(dist, self._dest)]
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/easy_install.py", line 1913, in _move_to_eggs_dir_and_compile
    unpacker(dist.location, tmp_dest)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/lib/python3.8/site-packages/zc/buildout/easy_install.py", line 1847, in unpack_wheel
    wheel.install_as_egg(os.path.join(dest, wheel.egg_name()))
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/wheel.py", line 110, in install_as_egg
    self._install_as_egg(destination_eggdir, zf)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/wheel.py", line 118, in _install_as_egg
    self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/wheel.py", line 167, in _convert_metadata
    setup_dist = setuptools.Distribution(
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/dist.py", line 475, in __init__
    _Distribution.__init__(
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/dist.py", line 898, in finalize_options
    for ep in sorted(loaded, key=by_order):
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/dist.py", line 897, in <lambda>
    loaded = map(lambda e: e.load(), filtered)
  File "/home/mcfaddenm/repos/plone5.2_clean/rfasite/rfasite/eggs/setuptools-65.7.0-py3.8.egg/setuptools/_vendor/importlib_metadata/__init__.py", line 196, in load
    return functools.reduce(getattr, attrs, module)
AttributeError: type object 'Distribution' has no attribute '_finalize_feature_opts'

Debugging sent me deep into python package management. I don't belong in that code - unless someone else thinks the entire community needs to be there...

But no one else in Plone is seeing this... so it must be me being me?

Plan B is to supply a versions.cfg with the specific packages noted in 20230921 update, but that feels a bit dirty. Best to be on a nice, pinned Plone distribution.

Not sure if I was having the same error, but, have you tried to delete the virtualenv and re-create it? It might as well be that some library is there getting in the way...

Just gave it a try. No dice. Although it was a good idea!

More specifically, my installation has a step to build the venv directly onto the install directory:

$ python3.9 -m venv .

So, deleting the virtualenv was kind of awkward, but basically:

$ rm -rf bin
$ rm -rf include
$ rm -rf lib
$ rm -rf lib64 
$ rm -rf pyvenv.cfg 
$ rm -rf share/

Then
$ python3.9 -m venv .
$ ./bin/pip install -r requirements.txt
$ ./bin/buildout

Which does repeat the error.

Also, just to make sure things are very clean:
$rm -rf eggs

requirements.txt:

setuptools==65.7.0
zc.buildout==3.0.1
wheel==0.38.4

I might try python3.10 for fun. but 3.9 is officially supported, so.... ?

I'll continue hacking at it and report any interesting results I get. This is a weird one.

Not sure if this is a clue, but the failure happens during:

Getting distribution for 'plone.recipe.zope2instance'.

But I've seen it fail on other eggs, yet other eggs will work, and I'm pretty sure I've gotten past zope2instance before. I think this is the failure only because I wiped my eggs before trying again.

1 Like

Same problem on upgrading from 5.2.13 to 5.2.14 with Python 3.8.9.

buildout runs successfully after

  • Recreating of venv with Python 3.8.19
  • pip install -r requirements.txt
   -c constraints.txt
  setuptools  
  zc.buildout  
  wheel

constraints.txt:

  pip==23.0.1
  setuptools==65.7.0
  zc.buildout==3.0.1
  wheel==0.38.4
  configparser==6.0.0
  • ./bin/buildout
1 Like