buruzaemon / natto-py

natto-py combines the Python programming language with MeCab, the part-of-speech and morphological analyzer for the Japanese language.
BSD 2-Clause "Simplified" License
92 stars 13 forks source link

Failed to install natto-py when setuptools 58.0 or later is used #119

Closed yacchi closed 2 years ago

yacchi commented 2 years ago

When I try to install natto-py, I got an error message and it fails.

I found that support for "2to3" has been removed in setuptools v58.0.0, and this seems to be the cause of the failure. https://setuptools.readthedocs.io/en/latest/history.html#v58-0-0

According to the setuptools changelog, there is a way to pinning the version of setuptools. However, if there are libraries that depend on newer versions of setuptools in the future, it will not be possible to install them again. Is there any way to support v58.0.0 or later?

I tried to install natto-py on the Python Official Docker image:

docker run --rm -it python:3.8.12-slim /bin/bash

root@adfb2aabfe82:/# pip list
# Check versions
Package    Version
---------- -------
pip        21.2.4
setuptools 57.5.0
wheel      0.37.0

# Update setuptools to latest
root@adfb2aabfe82:/# pip install -U setuptools
Requirement already satisfied: setuptools in /usr/local/lib/python3.8/site-packages (57.5.0)
Collecting setuptools
  Downloading setuptools-58.0.4-py3-none-any.whl (816 kB)
     |████████████████████████████████| 816 kB 18.7 MB/s 
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 57.5.0
    Uninstalling setuptools-57.5.0:
      Successfully uninstalled setuptools-57.5.0
Successfully installed setuptools-58.0.4

# Check version for setuptools
root@adfb2aabfe82:/# pip list
Package    Version
---------- -------
pip        21.2.4
setuptools 58.0.4
wheel      0.37.0

# Install natto-py
root@adfb2aabfe82:/# pip install natto-py==0.9.2
Collecting natto-py==0.9.2
  Downloading natto-py-0.9.2.tar.gz (36 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ioi8b7rl/natto-py_926cb52125074938b65122c2c6b226a8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ioi8b7rl/natto-py_926cb52125074938b65122c2c6b226a8/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ixswsg_v
         cwd: /tmp/pip-install-ioi8b7rl/natto-py_926cb52125074938b65122c2c6b226a8/
    Complete output (1 lines):
    error in natto-py setup command: use_2to3 is invalid.
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/f1/14/1d4258247a00b7b8a115563effb1d0bd30501d69580629d36593ce0af92d/natto-py-0.9.2.tar.gz#sha256=f1538230fd2f96b916f95b8d9972e3fbd4f558573b8ef7e8b711394102c35191 (from https://pypi.org/simple/natto-py/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement natto-py==0.9.2 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.1.0, 0.2.1, 0.3.1, 0.4.0, 0.5.0, 0.5.1, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.9.2)
ERROR: No matching distribution found for natto-py==0.9.2
buruzaemon commented 2 years ago

Hello @yacchi, and thank you for bringing this to my attention. I will take a closer look at this later this evening.

buruzaemon commented 2 years ago

Strange, but this issue does not appear to be reproducible on Windows.

However, it is easily apparent on Mac, and obviously on Linux as well.

I think the best thing may be to finally drop support for Python2, so that we will not need the use_2to3 bit...

yacchi commented 2 years ago

How about not using "use_2to3" when setuptools is 58 or later? (setuptools does not support Python2 for versions after 45).

However, since Python2 is already EoL and this project is very stable, I prefer to drop support for Python2 because it's easier to understand.

buruzaemon commented 2 years ago

How about not using "use_2to3" when setuptools is 58 or later? Yes, I thought about that...

However, since Python2 is already EoL and this project is very stable, I prefer to drop support for Python2 because it's easier to understand. ... but as you say, dropping Python2 support would make things much simpler. I think if anyone is still using Python2 and natto-py, they can just continue using v0.9.2.

Please give me some time to remove the Python2 support bits, and then make a new release.

Thank you for your patience!

buruzaemon commented 2 years ago

@yacchi. I apologize for making you wait, but I have finished making changes to remove support for Python 2. These changes will resolve the issue you reported with setuptools and the "use_2to3" feature. I will be releasing 1.0.0 later this evening.

buruzaemon commented 2 years ago

OK, the natto-py 1.0.0 release is now available. @yacchi, could you please try 1.0.0 and see if we have resolved the problem with setuptools and use_2to3?

yacchi commented 2 years ago

@buruzaemon Thanks for the update! I tried both the steps above and poetry and was able to install it correctly.