pasteorg / paste

Python Paste (core) repository
Other
59 stars 47 forks source link

ImportError with setuptools 50.1.0 #57

Closed hrnciar closed 4 years ago

hrnciar commented 4 years ago

Hello,

paste's setup.py is not working with the latest version of setuptools 50.1+. I am getting this error:

Traceback (most recent call last):
  File "/builddir/build/BUILD/Paste-3.4.0/setup.py", line 26, in <module>
    setup(name="Paste",
  File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib64/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib64/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/usr/lib64/python3.9/distutils/command/install.py", line 569, in run
    self.run_command(cmd_name)
  File "/usr/lib64/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.9/site-packages/setuptools/command/install_scripts.py", line 17, in run
    import setuptools.command.easy_install as ei
  File "/usr/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 52, in <module>
    from setuptools.package_index import (
  File "/usr/lib/python3.9/site-packages/setuptools/package_index.py", line 13, in <module>
    import html
  File "/builddir/build/BUILD/Paste-3.4.0/paste/util/html.py", line 8, in <module>
    from html import escape
ImportError: cannot import name 'escape' from partially initialized module 'html' (most likely due to a circular import) (/builddir/build/BUILD/Paste-3.4.0/paste/util/html.py)

Problem is that setuptools started to use the standard library html module which name-conflicts with paste.util.html. Paste's setup.py inserts paste/util tosys.path:

https://github.com/cdent/paste/blob/3.4.0/setup.py#L19

And hence setuptools, when importing html, imports paste/util/html.py which tries to import html as well, imports paste/util/html.py...

I would suggest to delete paste/util from sys.path after importing finddata. This way setuptools will use the correct html module (or any other name-clashing module).

Have a nice day, Tomas

cdent commented 4 years ago

Thanks for noticing this and diagnosing. If you're able to provide a pull request with the necessary changes that would be fantastic and would accelerate the process of getting the fix released. Let me know.