redhat-openstack / infrared

Plugin based framework that aims to provide an easy-to-use CLI for Ansible based projects
https://infrared.readthedocs.io/en/latest/index.html
Apache License 2.0
99 stars 97 forks source link

Python 3 Support #370

Open LukeShortCloud opened 4 years ago

LukeShortCloud commented 4 years ago

With upstream Python 2 going end-of-life in a few months, it might be a good idea to start working on compatibility with Python 3. The documentation states that only Python 2.7 is supported. Distributions such as Fedora 32 are planning to remove most of the Python 2 libraries.

Currently, installing with pip via Python 3 fails with this error below. There are likely more issues to be addressed beyond this.

$ pip3 install infrared
Collecting infrared
  Downloading https://files.pythonhosted.org/packages/40/62/2b8c7ea3df7bbb98e7fa9ab6d5083ab47c78c553c7f954514bfa5819a33f/infrared-2.0.0rc1.tar.gz (126kB)
     |████████████████████████████████| 133kB 1.0MB/s 
    ERROR: Command errored out with exit status 1:
     command: /home/user/venv_infarered/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a4egy9u9/infrared/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a4egy9u9/infrared/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-a4egy9u9/infrared/pip-egg-info
         cwd: /tmp/pip-install-a4egy9u9/infrared/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-a4egy9u9/infrared/setup.py", line 3, in <module>
        from pip import req
    ImportError: cannot import name 'req' from 'pip' (/home/user/venv_infarered/lib/python3.7/site-packages/pip/__init__.py)
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ariemaron commented 4 years ago

As a work around, you can roll back to pip3 version 9.0.3.

python3 -m pip install pip==9.0.3

It seems that there is no pip.req module in versions later than this