avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
345 stars 343 forks source link

Failed to install MarkupSafe when installing the html plugin via `python3 setup.py install` #6038

Closed PaulYuuu closed 1 month ago

PaulYuuu commented 1 month ago

Describe the bug When installing the avocado-framework-plugin-result-html plugin via python3 setup.py install, the plugin failed to install cause the setuptools version was outdated.

Steps to reproduce

cd avocado/optional_plugins/html
python3 setup.py install

Expected behavior

Using /root/.pyenv/versions/3.9.20/envs/kartest/lib/python3.9/site-packages/avocado_framework-108.0-py3.9.egg
Searching for MarkupSafe==3.0.1
Best match: MarkupSafe 3.0.1
Adding MarkupSafe 3.0.1 to easy-install.pth file

Using /root/.pyenv/versions/3.9.20/envs/kartest/lib/python3.9/site-packages
Searching for setuptools==58.1.0
Best match: setuptools 58.1.0
Adding setuptools 58.1.0 to easy-install.pth file

Using /root/.pyenv/versions/3.9.20/envs/kartest/lib/python3.9/site-packages
Finished processing dependencies for avocado-framework-plugin-result-html==108.0

Current behavior

Searching for MarkupSafe>=2.0
Reading https://pypi.org/simple/MarkupSafe/
Downloading https://files.pythonhosted.org/packages/b4/d2/38ff920762f2247c3af5cbbbbc40756f575d9692d381d7c520f45deb9b8f/markupsafe-3.0.1.tar.gz#sha256=3e683ee4f5d0fa2dde4db77ed8dd8a876686e3fc417655c2ece9a90576905344
Best match: markupsafe 3.0.1
Processing markupsafe-3.0.1.tar.gz
Writing /tmp/easy_install-3bj198h3/markupsafe-3.0.1/setup.cfg
Running markupsafe-3.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-3bj198h3/markupsafe-3.0.1/egg-dist-tmp-l1mzkbx0
Traceback (most recent call last):
  File "/root/.pyenv/versions/kartest/lib/python3.9/site-packages/setuptools/sandbox.py", line 156, in save_modules
    yield saved
  File "/root/.pyenv/versions/kartest/lib/python3.9/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/root/.pyenv/versions/kartest/lib/python3.9/site-packages/setuptools/sandbox.py", line 259, in run_setup
    _execfile(setup_script, ns)
  File "/root/.pyenv/versions/kartest/lib/python3.9/site-packages/setuptools/sandbox.py", line 46, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-3bj198h3/markupsafe-3.0.1/setup.py", line 8, in <module>
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
ImportError: cannot import name 'CCompilerError' from 'setuptools.errors' (/root/.pyenv/versions/kartest/lib/python3.9/site-packages/setuptools/errors.py)

System information (please complete the following information):

Additional information Workarounds:

  1. Install MarkupSafe before avocado installation: pip install MarkupSafe --> python3 setup.py install
  2. Add MarkupSafe<3.0.0 in html's setup.py
PaulYuuu commented 1 month ago

Hello @clebergnu @richtja, although I think this is a MarkupSafe bug, I still want to discuss it with you.

From MarkupSafe>=3.0.0, it introduces from setuptools.errors import CCompilerError in setup.py. However, this behavior requires setuptools>=59.0, but the version provided by RHEL9 system is python3-setuptools-53.0.0-13.el9.noarch. We can use pip install instead of python3 setup.py install, but I checked the repo usage, still have some setup.py install/develop. Do you have some opinions?

E.g.

  1. Upgrade pip/setuptools before avocado installation
  2. Disable all setup.py usage
  3. Move our repo to support pyproject.toml for more morden features.
richtja commented 1 month ago

Hi @PaulYuuu, yes we are aware that there might be dependency issues with setuptools, also the setuptools is not shipped with python3.12 anymore. Therefore, we plan to work on complete removal of setuptools dependency in #5754 and that should also fix this issue. But for now, I think we can add the MarkupSafe<3.0.0 requirement to html plugin. Would that be useful for you?

PaulYuuu commented 1 month ago

Hello @richtja, this is not an urgent task, I already pick workaround 1 in our internal repo, but if someone has the same problem, you can decide to apply it. And seems that not all platforms can trigger it, MarkupSafe provides wheel for x86 and aarch64(https://github.com/pallets/markupsafe/releases), so I believe they will not hit this issue.

And yes, setuptools is not shipped with python3.12 together, however if we plan to remove this dependency, we have to choose another build system, which can be hatchling/poetry. I tried to migrate avocado to pyproject.toml with still using setuptools https://github.com/avocado-framework/avocado/pull/5962/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711, but many custom targets in setup.py I cannot handle them.

Another example is the VT one: https://github.com/avocado-framework/avocado-vt/pull/3924

richtja commented 1 month ago

Hello @richtja, this is not an urgent task, I already pick workaround 1 in our internal repo, but if someone has the same problem, you can decide to apply it. And seems that not all platforms can trigger it, MarkupSafe provides wheel for x86 and aarch64(https://github.com/pallets/markupsafe/releases), so I believe they will not hit this issue.

I just found out that our CI catch this, therefore I need to add the MarkupSafe<3.0.0 requirement to html plugin.

And yes, setuptools is not shipped with python3.12 together, however if we plan to remove this dependency, we have to choose another build system, which can be hatchling/poetry. I tried to migrate avocado to pyproject.toml with still using setuptools https://github.com/avocado-framework/avocado/pull/5962/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711, but many custom targets in setup.py I cannot handle them.

Another example is the VT one: avocado-framework/avocado-vt#3924

Thank you for all that work, I will look into this.