Pull requests

#32 Merged
Repository
diogobaeder diogobaeder
Branch
default
Repository
tarek tarek
Branch
develop

Fixing install problem for Python 3

Author
  1. Diogo Baeder
Reviewers
Description

Trying to install flake8, latest version, in a clean virtualenv fails:

$ ▶pip install -U flake8
Downloading/unpacking flake8 from http://pypi.python.org/packages/source/f/flake8/flake8-2.0.tar.gz#md5=176c6b3613777122721db181560aa1e3
  Downloading flake8-2.0.tar.gz
  Running setup.py egg_info for package flake8

Downloading/unpacking distribute from http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz#md5=e55298c7e3a233df1a47a4881a0c9800 (from flake8)
  Downloading distribute-0.6.35.tar.gz (644kB): 644kB downloaded
  Running setup.py egg_info for package distribute
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "./setuptools/__init__.py", line 2, in <module>
        from setuptools.extension import Extension, Library
      File "./setuptools/extension.py", line 5, in <module>
        from setuptools.dist import _get_unpatched
      File "./setuptools/dist.py", line 103
        except ValueError, e:
                         ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "./setuptools/__init__.py", line 2, in <module>

    from setuptools.extension import Extension, Library

  File "./setuptools/extension.py", line 5, in <module>

    from setuptools.dist import _get_unpatched

  File "./setuptools/dist.py", line 103

    except ValueError, e:

                     ^

SyntaxError: invalid syntax

This happens because flake8 depends on the setuptools package (which doesn't make much sense to me, but maybe I'm wrong), which itself depends on distribute, whose latest version (0.6.35) contains the syntax error.

So, what I did was to just take setuptools out of play, as I think it should have already been installed by the time the user tries to install flake8.

Comments (17)

  1. Diogo Baeder author

    Hey guys, sorry to post this here, but is there any discussion forum, or another way we can talk directly, without having to open an issue? I'd like to help with the project and propose some improvements, but can't find a communication channel through which I can reach you. :-(

  2. Ian Cordasco

    (flake8-py3)iapetus:~/virtualenv/flake8-py3 python -V Python 3.2.1 (flake8-py3)iapetus:~/virtualenv/flake8-py3 flake8 --version 2.0 (pep8: 1.4.4, pyflakes: 0.6.1, mccabe: 0.2) CPython 3.2.1 on Linux

    I'm running the develop branch but it still has the setuptools dependency.

    You can email me at least. I'll send you my email address.

  3. Diogo Baeder author

    So, I guess that was maybe a problem with my virtualenv, then. However, setuptools still has that issue, and I think it would be interesting not to put it as requirement as it's unreliable in a Python 3 environment. This is what I get with a fresh py3.2 venv:

     flake8-py3.2 ▶ ~ ❯ tmp ▶ $ ▶pip install setuptools
    Requirement already satisfied (use --upgrade to upgrade): distribute in /home/diogobaeder/Envs/flake8-py3.2/lib/python3.2/site-packages/distribute-0.6.31-py3.2.egg
    Cleaning up...
     flake8-py3.2 ▶ ~ ❯ tmp ▶ $ ▶pip install -U setuptools
    Downloading/unpacking distribute from http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz#md5=e55298c7e3a233df1a47a4881a0c9800
      Downloading distribute-0.6.35.tar.gz (644kB): 644kB downloaded
      Running setup.py egg_info for package distribute
        Traceback (most recent call last):
          File "<string>", line 3, in <module>
          File "setuptools/__init__.py", line 2, in <module>
            from setuptools.extension import Extension, Library
          File "setuptools/extension.py", line 5, in <module>
            from setuptools.dist import _get_unpatched
          File "setuptools/dist.py", line 103
            except ValueError, e:
                             ^
        SyntaxError: invalid syntax
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 3, in <module>
    
      File "setuptools/__init__.py", line 2, in <module>
    
        from setuptools.extension import Extension, Library
    
      File "setuptools/extension.py", line 5, in <module>
    
        from setuptools.dist import _get_unpatched
    
      File "setuptools/dist.py", line 103
    
        except ValueError, e:
    
                         ^
    
    SyntaxError: invalid syntax
    
    ----------------------------------------
    Command python setup.py egg_info failed with error code 1 in /home/diogobaeder/Envs/flake8-py3.2/build/distribute
    Storing complete log in /home/diogobaeder/.pip/pip.log
    
  4. Diogo Baeder author

    So, now I understand what happened: My project was using flake==1.7.0, and the problem happened when trying to upgrade to 2.0 (because it tries to upgrade setuptools as well, hence leading to the error).

    This is a clear way to reproduce the error:

     ~ ❯ tmp ▶ $ ▶mkvirtualenv some-project -p python3.2
    Running virtualenv with interpreter /usr/bin/python3.2
    New python executable in some-project/bin/python3.2
    Also creating executable in some-project/bin/python
    Please make sure you remove any previous custom paths from your /home/diogobaeder/.pydistutils.cfg file.
    Installing distribute......................................................................................................................................................................................................................................................................................................................................................................................................done.
    Installing pip................done.
     ~ ❯ tmp ▶ $ ▶workon some-project
     some-project ▶ ~ ❯ tmp ▶ $ ▶pip install flake8==1.7.0 # because this project was still using the old version
    Downloading/unpacking flake8==1.7.0
      Downloading flake8-1.7.0.tar.gz (42kB): 42kB downloaded
      Running setup.py egg_info for package flake8
    
    Installing collected packages: flake8
      Running setup.py install for flake8
        changing mode of build/scripts-3.2/flake8 from 664 to 775
        deleting flake8.egg-info/entry_points.txt
    
        changing mode of /home/diogobaeder/Envs/some-project/bin/flake8 to 775
    Successfully installed flake8
    Cleaning up...
     some-project ▶ ~ ❯ tmp ▶ $ ▶pip install -U flake8
    Downloading/unpacking flake8 from http://pypi.python.org/packages/source/f/flake8/flake8-2.0.tar.gz#md5=176c6b3613777122721db181560aa1e3
      Downloading flake8-2.0.tar.gz
      Running setup.py egg_info for package flake8
    
    Downloading/unpacking distribute from http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz#md5=e55298c7e3a233df1a47a4881a0c9800 (from flake8)
      Downloading distribute-0.6.35.tar.gz (644kB): 644kB downloaded
      Running setup.py egg_info for package distribute
        Traceback (most recent call last):
          File "<string>", line 3, in <module>
          File "setuptools/__init__.py", line 2, in <module>
            from setuptools.extension import Extension, Library
          File "setuptools/extension.py", line 5, in <module>
            from setuptools.dist import _get_unpatched
          File "setuptools/dist.py", line 103
            except ValueError, e:
                             ^
        SyntaxError: invalid syntax
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 3, in <module>
    
      File "setuptools/__init__.py", line 2, in <module>
    
        from setuptools.extension import Extension, Library
    
      File "setuptools/extension.py", line 5, in <module>
    
        from setuptools.dist import _get_unpatched
    
      File "setuptools/dist.py", line 103
    
        except ValueError, e:
    
                         ^
    
    SyntaxError: invalid syntax
    
    ----------------------------------------
    Command python setup.py egg_info failed with error code 1 in /home/diogobaeder/Envs/some-project/build/distribute
    Storing complete log in /home/diogobaeder/.pip/pip.log
    
  5. Ian Cordasco

    I wonder if a conditional addition to the requirements would work. Something like,

    try:
        from setuptools import setup
    except ImportError:
        from distutils.core import setup
        requirements.append('setuptools')
    

    But I think distutils might choke on entry_points. Perhaps we just drop it and we catch the ImportError and re-throw it telling the user to install setuptools first?

  6. Diogo Baeder author

    My guts say we should just drop the line, and let the user know of the problem if it happens. The vast majority won't even hit this situation.

    BTW, now we have a conflict (the main.py file seems to have changed after this pull request), I'll fix it and push again.

  7. Ian Cordasco

    You committed a merge conflict possibly, although it could just be BitBucket displaying the file like that. I'll sort it out. I just want to check with Florent Xicluna that we do not actually need setuptools as a requirement (or rather, that he's ok with removing it as one).

  8. Florent Xicluna

    you can blame me for the conflict :-)

    I agree we should remove setuptools as dependency or just disable it and add a comment with reference to the upstream issue (either pip or distribute).

    The issue should be reported and fixed in pep8 too.

    As a workaround, you can avoid the -U and do:

    pip uninstall pep8
    pip uninstall pyflakes
    pip uninstall flake8
    pip install flake8
    

    If I'm not wrong, it should install the latest.

  9. Ian Cordasco

    I think we'll have to wait for the next release of pep8 to also fix the other issue with users running flake8 with no options on Windows. No need to do 2 minor releases when one will suffice.

  10. Ian Cordasco

    If I recall correctly, the last release of flake8 did not strictly pin the dependencies so upgrading mccabe alone should be fine without a new release for flake8. We have some items that need to be fixed before then anyway.