AssertionError running buildout in Apple Silicon

So, today buildout suddenly stopped working on my M1 macbook air. Buildout fails with AssertionError while trying to getting some packages.

While:
  Installing.
  Getting section instance.
  Initializing section instance.
  Installing recipe plone.recipe.zope2instance.
  Getting distribution for 'zope.interface==5.5.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 "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 2252, in main
    getattr(buildout, command)(args)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 740, in install
    [self[part]['recipe'] for part in install_parts]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 740, in <listcomp>
    [self[part]['recipe'] for part in install_parts]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1373, in __getitem__
    options._initialize()
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1481, in _initialize
    self.initialize()
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1487, in initialize
    recipe_class = _install_and_load(reqs, 'zc.buildout', entry, buildout)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1430, in _install_and_load
    zc.buildout.easy_install.install(
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 971, in install
    return installer.install(specs, working_set)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 744, in install
    for dist in self._get_dist(req, ws):
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 581, in _get_dist
    dists = [_move_to_eggs_dir_and_compile(dist, self._dest)]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 1948, in _move_to_eggs_dir_and_compile
    assert newdist is not None  # newloc above is missing our dist?!
AssertionError

This only seem to happen with packages that have a prebuilt arm64 package, like zope.interface or zope.security. If I ran buildout again the error changes:

While:
  Installing.
  Getting section instance.
  Initializing section instance.
  Installing recipe plone.recipe.zope2instance.
  Getting distribution for 'zope.interface==5.5.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 "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 2252, in main
    getattr(buildout, command)(args)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 740, in install
    [self[part]['recipe'] for part in install_parts]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 740, in <listcomp>
    [self[part]['recipe'] for part in install_parts]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1373, in __getitem__
    options._initialize()
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1481, in _initialize
    self.initialize()
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1487, in initialize
    recipe_class = _install_and_load(reqs, 'zc.buildout', entry, buildout)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/buildout.py", line 1430, in _install_and_load
    zc.buildout.easy_install.install(
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 971, in install
    return installer.install(specs, working_set)
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 744, in install
    for dist in self._get_dist(req, ws):
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 581, in _get_dist
    dists = [_move_to_eggs_dir_and_compile(dist, self._dest)]
  File "/Users/alexandre/dev/plone/dev/venv/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 1922, in _move_to_eggs_dir_and_compile
    os.rename(tmp_loc, newloc)
OSError: [Errno 66] Directory not empty: '/Users/alexandre/dev/plone/dev/eggs/cp39/tmpb1ic289d/zope.interface-5.5.2-py3.9-macosx-12.4-arm64.egg' -> '/Users/alexandre/dev/plone/dev/eggs/cp39/zope.interface-5.5.2-py3.9-macosx-12.4-arm64.egg'

To solve it I had to install some packaged using pip inside the virtual env.

My config is:

  • MacOS Ventura 13.2
  • python 3.9.13
  • Plone 5.2.11
  • setuptools 65.7.0
  • zc.buildout 3.0.1
  • wheel 0.38.4

Already tried the same buildout config in ubuntu and it works perfectly.