apertium/apertium-python

Doesn't install on Debian GNU/Linux 9 (stretch)

Closed this issue · 2 comments

$ pip3 install apertium
Collecting apertium
  Downloading https://files.pythonhosted.org/packages/bc/0a/b75646773a53aa8318ecb164b2d9e39889cf458097b67abd6cc6dba0b9dc/apertium-0.2.3.tar.gz
Requirement already satisfied: apertium-streamparser==5.0.2 in /home/fran/local/lib/python3.7/site-packages/apertium_streamparser-5.0.2-py3.7.egg (from apertium) (5.0.2)
Building wheels for collected packages: apertium
  Running setup.py bdist_wheel for apertium ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2qgtcwm1/apertium/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-vg0xk_8n --python-tag cp38:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/apertium
  copying apertium/mode_search.py -> build/lib/apertium
  copying apertium/__init__.py -> build/lib/apertium
  copying apertium/installer.py -> build/lib/apertium
  copying apertium/utils.py -> build/lib/apertium
  copying apertium/iso639.py -> build/lib/apertium
  creating build/lib/apertium/generation
  copying apertium/generation/__init__.py -> build/lib/apertium/generation
  creating build/lib/apertium/tagger
  copying apertium/tagger/__init__.py -> build/lib/apertium/tagger
  creating build/lib/apertium/translation
  copying apertium/translation/__init__.py -> build/lib/apertium/translation
  creating build/lib/apertium/analysis
  copying apertium/analysis/__init__.py -> build/lib/apertium/analysis
  copying apertium/py.typed -> build/lib/apertium
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/apertium
  creating build/bdist.linux-x86_64/wheel/apertium/generation
  copying build/lib/apertium/generation/__init__.py -> build/bdist.linux-x86_64/wheel/apertium/generation
  copying build/lib/apertium/py.typed -> build/bdist.linux-x86_64/wheel/apertium
  copying build/lib/apertium/mode_search.py -> build/bdist.linux-x86_64/wheel/apertium
  creating build/bdist.linux-x86_64/wheel/apertium/tagger
  copying build/lib/apertium/tagger/__init__.py -> build/bdist.linux-x86_64/wheel/apertium/tagger
  copying build/lib/apertium/__init__.py -> build/bdist.linux-x86_64/wheel/apertium
  copying build/lib/apertium/installer.py -> build/bdist.linux-x86_64/wheel/apertium
  copying build/lib/apertium/utils.py -> build/bdist.linux-x86_64/wheel/apertium
  creating build/bdist.linux-x86_64/wheel/apertium/translation
  copying build/lib/apertium/translation/__init__.py -> build/bdist.linux-x86_64/wheel/apertium/translation
  copying build/lib/apertium/iso639.py -> build/bdist.linux-x86_64/wheel/apertium
  creating build/bdist.linux-x86_64/wheel/apertium/analysis
  copying build/lib/apertium/analysis/__init__.py -> build/bdist.linux-x86_64/wheel/apertium/analysis
  running install_egg_info
  running egg_info
  writing apertium.egg-info/PKG-INFO
  writing dependency_links to apertium.egg-info/dependency_links.txt
  writing requirements to apertium.egg-info/requires.txt
  writing top-level names to apertium.egg-info/top_level.txt
  reading manifest file 'apertium.egg-info/SOURCES.txt'
  writing manifest file 'apertium.egg-info/SOURCES.txt'
  Copying apertium.egg-info to build/bdist.linux-x86_64/wheel/apertium-0.2.3.egg-info
  running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 47, in <module>
      setup(
    File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 140, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 224, in run
      self.run_command('install')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 29, in run
      install_binaries()
    File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 15, in install_binaries
      apertium.installer.install_apertium()
    File "/tmp/pip-install-2qgtcwm1/apertium/apertium/installer.py", line 164, in install_apertium
      installer = get_installer()
    File "/tmp/pip-install-2qgtcwm1/apertium/apertium/installer.py", line 158, in get_installer
      raise apertium.InstallationNotSupported(distro_name)
  apertium.InstallationNotSupported: Debian GNU/Linux 9 (stretch)
  
  ----------------------------------------
  Failed building wheel for apertium
  Running setup.py clean for apertium
Failed to build apertium
Installing collected packages: apertium
  Running setup.py install for apertium ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2qgtcwm1/apertium/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-1mdx1tup/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/apertium
    copying apertium/mode_search.py -> build/lib/apertium
    copying apertium/__init__.py -> build/lib/apertium
    copying apertium/installer.py -> build/lib/apertium
    copying apertium/utils.py -> build/lib/apertium
    copying apertium/iso639.py -> build/lib/apertium
    creating build/lib/apertium/generation
    copying apertium/generation/__init__.py -> build/lib/apertium/generation
    creating build/lib/apertium/tagger
    copying apertium/tagger/__init__.py -> build/lib/apertium/tagger
    creating build/lib/apertium/translation
    copying apertium/translation/__init__.py -> build/lib/apertium/translation
    creating build/lib/apertium/analysis
    copying apertium/analysis/__init__.py -> build/lib/apertium/analysis
    copying apertium/py.typed -> build/lib/apertium
    running install_lib
    creating /home/fran/.local/lib/python3.8/site-packages/apertium
    creating /home/fran/.local/lib/python3.8/site-packages/apertium/generation
    copying build/lib/apertium/generation/__init__.py -> /home/fran/.local/lib/python3.8/site-packages/apertium/generation
    copying build/lib/apertium/py.typed -> /home/fran/.local/lib/python3.8/site-packages/apertium
    copying build/lib/apertium/mode_search.py -> /home/fran/.local/lib/python3.8/site-packages/apertium
    creating /home/fran/.local/lib/python3.8/site-packages/apertium/tagger
    copying build/lib/apertium/tagger/__init__.py -> /home/fran/.local/lib/python3.8/site-packages/apertium/tagger
    copying build/lib/apertium/__init__.py -> /home/fran/.local/lib/python3.8/site-packages/apertium
    copying build/lib/apertium/installer.py -> /home/fran/.local/lib/python3.8/site-packages/apertium
    copying build/lib/apertium/utils.py -> /home/fran/.local/lib/python3.8/site-packages/apertium
    creating /home/fran/.local/lib/python3.8/site-packages/apertium/translation
    copying build/lib/apertium/translation/__init__.py -> /home/fran/.local/lib/python3.8/site-packages/apertium/translation
    copying build/lib/apertium/iso639.py -> /home/fran/.local/lib/python3.8/site-packages/apertium
    creating /home/fran/.local/lib/python3.8/site-packages/apertium/analysis
    copying build/lib/apertium/analysis/__init__.py -> /home/fran/.local/lib/python3.8/site-packages/apertium/analysis
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/generation/__init__.py to __init__.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/mode_search.py to mode_search.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/tagger/__init__.py to __init__.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/__init__.py to __init__.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/installer.py to installer.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/utils.py to utils.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/translation/__init__.py to __init__.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/iso639.py to iso639.cpython-38.pyc
    byte-compiling /home/fran/.local/lib/python3.8/site-packages/apertium/analysis/__init__.py to __init__.cpython-38.pyc
    running install_egg_info
    running egg_info
    writing apertium.egg-info/PKG-INFO
    writing dependency_links to apertium.egg-info/dependency_links.txt
    writing requirements to apertium.egg-info/requires.txt
    writing top-level names to apertium.egg-info/top_level.txt
    reading manifest file 'apertium.egg-info/SOURCES.txt'
    writing manifest file 'apertium.egg-info/SOURCES.txt'
    Copying apertium.egg-info to /home/fran/.local/lib/python3.8/site-packages/apertium-0.2.3.egg-info
    running install_scripts
    writing list of installed files to '/tmp/pip-record-1mdx1tup/install-record.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 47, in <module>
        setup(
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 140, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 29, in run
        install_binaries()
      File "/tmp/pip-install-2qgtcwm1/apertium/setup.py", line 15, in install_binaries
        apertium.installer.install_apertium()
      File "/tmp/pip-install-2qgtcwm1/apertium/apertium/installer.py", line 164, in install_apertium
        installer = get_installer()
      File "/tmp/pip-install-2qgtcwm1/apertium/apertium/installer.py", line 158, in get_installer
        raise apertium.InstallationNotSupported(distro_name)
    apertium.InstallationNotSupported: Debian GNU/Linux 9 (stretch)
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2qgtcwm1/apertium/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-1mdx1tup/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-2qgtcwm1/apertium/

Seems like an easy fix:

with open('/etc/os-release') as os_release:
distro_name = os_release.readline().split('=')[-1].strip().replace('"', '')
if distro_name == 'Ubuntu':
return Ubuntu()
else:
raise apertium.InstallationNotSupported(distro_name)

Stretch is too old (Py 3.5), but it will now install on Debian and Ubuntu with Python 3 >= 3.6. Tested on Debian Buster and Ubuntu Bionic.