buildout / buildout

Buildout is a deployment automation tool written in and extended with Python
http://www.buildout.org
Other
570 stars 168 forks source link

setuptools vendoring of distutils breaks `zc.buildout` (and `dev.py`) #600

Closed gotcha closed 2 years ago

gotcha commented 2 years ago

See https://github.com/buildout/buildout/pull/599

/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
[646](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:646)
  EasyInstallDeprecationWarning,
[647](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:647)
/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
[648](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:648)
  setuptools.SetuptoolsDeprecationWarning,
[649](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:649)
Traceback (most recent call last):
[650](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:650)
  File "dev.py", line 167, in <module>
[651](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:651)
    import zc.buildout.easy_install
[652](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:652)
  File "/home/buildout/sandbox/src/zc/buildout/__init__.py", line 17, in <module>
[653](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:653)
    import zc.buildout.patches # NOQA
[654](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:654)
  File "/home/buildout/sandbox/src/zc/buildout/patches.py", line 166, in <module>
[655](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:655)
    patch_PackageIndex()
[656](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:656)
  File "/home/buildout/sandbox/src/zc/buildout/patches.py", line 44, in patch_PackageIndex
[657](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:657)
    from setuptools.package_index import PackageIndex
[658](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:658)
  File "/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 8, in <module>
[659](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:659)
    import _distutils_hack.override  # noqa: F401
[660](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:660)
  File "/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/_distutils_hack/override.py", line 1, in <module>
[661](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:661)
    __import__('_distutils_hack').do_override()
[662](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:662)
  File "/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/_distutils_hack/__init__.py", line 71, in do_override
[663](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:663)
    ensure_local_distutils()
[664](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:664)
  File "/home/buildout/sandbox/pythons/3.7/lib/python3.7/site-packages/_distutils_hack/__init__.py", line 59, in ensure_local_distutils
[665](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:665)
    assert '_distutils' in core.__file__, core.__file__
[666](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:666)
AssertionError: /home/buildout/sandbox/pythons/3.7/lib/python3.7/distutils/core.py
[667](https://github.com/buildout/buildout/runs/5050371716?check_suite_focus=true#step:3:667)
make: *** [Makefile:81: build] Error 1
gotcha commented 2 years ago

My current understanding is the following:

setuptools is vendoring distutils. It installs a hack to ensure that its copy of distutils is used instead of the stdlib version. Unfortunately, there is still an issue with pip (https://github.com/pypa/pip/issues/8761) where the mechanism fails and where setuptools allow pip to use the stdlib version.

We are in the dark spot of the problem with zc.buildout>3 since it combines setuptoolsand pip.

gotcha commented 2 years ago
  ...
  File "/foo/env/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 57, in __init__
    raise TypeError("dist must be a Distribution instance")
TypeError: dist must be a Distribution instance

This is another symptom of the same issue with setuptools and pip.

gotcha commented 2 years ago

Fix released in https://pypi.org/project/zc.buildout/3.0.0rc3/

gotcha commented 2 years ago

@mauritsvanrees @icemac Would you try that latest release ?

I hope it is the last release candidate.

mauritsvanrees commented 2 years ago

I am trying it out in https://github.com/plone/buildout.coredev/pull/786 with latest setuptools 62.0.0.

So far so good:

Thanks a lot!

mauritsvanrees commented 2 years ago

A local buildout run without downloads or eggs cache is still running.

Update: it has finished successfully, after installing 309 packages:

$ ls -1 downloads/dist/ | wc -l
     309
$ ls -1 eggs/cp39/ | wc -l
     309
$ du -sh downloads/dist/ eggs/cp39/
 52M    downloads/dist/
205M    eggs/cp39/
mauritsvanrees commented 2 years ago

Jenkins has succeeded as well. I have merged my PR: the Plone 6.0 coredev buildout is now using release candidate 3.

gotcha commented 2 years ago

@mauritsvanrees

Thanks for testing it ! And for Plone 6 coredev.

Before cutting a 3.0 release, I still would like to test a buildout that pins a lower version of setuptools than the one installed in the virtualenv.

My intuition tells me that it is one of the cases where the race condition mentioned in https://github.com/pypa/pip/issues/8761 could happen. But I could be wrong.