Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more_itertools throws SyntaxError when pytest installed via setuptools #4772

Closed
dzieciou opened this issue Feb 12, 2019 · 4 comments
Closed

Comments

@dzieciou
Copy link

dzieciou commented Feb 12, 2019

I have the following minimal setup.py:

    import setuptools
    
    setuptools.setup(
        setup_requires=['pytest-runner'],
        tests_require=['mock', 'pytest'],
        test_suite='tests',
        python_requires='>=2.7',
    )

when running it with

    python setup.py test

I keep getting the following error:

Traceback (most recent call last):   File "setup.py", line 8, in

    <module>
        python_requires='>=2.7',   File "/Users/project/tmp/env/lib/python2.7/site-packages/setuptools/__init__.py",
    line 145, in setup
        return distutils.core.setup(**attrs)   File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py",
    line 151, in setup
        dist.run_commands()   File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",
    line 953, in run_commands
        self.run_command(cmd)   File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",
    line 972, in run_command
        cmd_obj.run()   File "/Users/project/tmp/.eggs/pytest_runner-4.2-py2.7.egg/ptr.py",
    line 176, in run
        return self.run_tests()   File "/Users/project/tmp/.eggs/pytest_runner-4.2-py2.7.egg/ptr.py",
    line 187, in run_tests
        result_code = __import__('pytest').main()   File "/Users/project/tmp/.eggs/pytest-4.2.0-py2.7.egg/pytest.py",
    line 14, in <module>
        from _pytest.fixtures import fillfixtures as _fillfuncargs   File "/Users/project/tmp/.eggs/pytest-4.2.0-py2.7.egg/_pytest/fixtures.py",
    line 16, in <module>
        from more_itertools import flatten   File "build/bdist.macosx-10.13-x86_64/egg/more_itertools/__init__.py", line
    1, in <module  File
    "/Users/project/tmp/.eggs/more_itertools-6.0.0-py2.7.egg/more_itertools/more.py",
    line 329
        def _collate(*iterables, key=lambda a: a, reverse=False):
                                   ^ SyntaxError: invalid syntax

The problem appears also in the tests of more_itertools that are executed during first run, when setup tools installs test dependencies:

    Downloading
    https://files.pythonhosted.org/packages/dd/f4/cdfbb6f07f767e0cd8a11b16adfecc735b6eb87dbebda026ce8898e1cc22/more-itertools-6.0.0.tar.gz#sha256=590044e3942351a1bdb1de960b739ff4ce277960f2425ad4509446dbace8d9d1
    Best match: more-itertools 6.0.0 Processing
    more-itertools-6.0.0.tar.gz Writing
    /var/folders/lq/c1ll7pqx7rb28p7m_8wz3h2d0r0mws/T/easy_install-Auek5Z/more-itertools-6.0.0/setup.cfg
    Running more-itertools-6.0.0/setup.py -q bdist_egg --dist-dir
    /var/folders/lq/c1ll7pqx7rb28p7m_8wz3h2d0r0mws/T/easy_install-Auek5Z/more-itertools-6.0.0/egg-dist-tmp-I3ic_t
    warning: no files found matching 'fabfile.py'   File
    "build/bdist.macosx-10.13-x86_64/egg/more_itertools/tests/test_more.py",
    line 892
        print(item, file=f)
                        ^ SyntaxError: invalid syntax
    
      File "build/bdist.macosx-10.13-x86_64/egg/more_itertools/more.py",
    line 329
        def _collate(*iterables, key=lambda a: a, reverse=False):
                                   ^ SyntaxError: invalid syntax
    
    zip_safe flag not set; analyzing archive contents... Copying
    more_itertools-6.0.0-py2.7.egg to /Users/project/tmp/.eggs
    
    Installed /Users/project/tmp/.eggs/more_itertools-6.0.0-py2.7.egg

The problem does not happen when I install more_itertools with

    pip install more_itertools

My environment

(env) MBP-OK-32:tmp maciej.gawinecki$ pip list
Package    Version
---------- -------
pip        19.0.2
setuptools 40.8.0
wheel      0.33.0
(env) MBP-OK-32:tmp maciej.gawinecki$ Python --version
Python 2.7.15

MacOS HighSierra version 10.13.6

@michel-iamit
Copy link

Note: when I pin more-itertools to 5.0.0. the problem is 'solved': more-itertools = 5.0.0 So either fix this bug, or pin it in the requirements <= 5.0.0 (last is not prefered, but solves it for now).

@dzieciou
Copy link
Author

dzieciou commented Feb 12, 2019

@iamIT Right. Thank you!

tests_require=['mock', 'pytest','more-itertools<=5.0.0'],

solved the problem. Coming from a Java/Maven work to Python, to me looks like dependency conlflict resolution. Or it is rather a workaround for a bug in pytest?

@sambrightman
Copy link

more_itertools 6.0.0 dropped support for Python 2.7.

sambrightman pushed a commit to sambrightman/pytest that referenced this issue Feb 12, 2019
@nicoddemus
Copy link
Member

Hi everyone, thanks for opening this issue.

I'm closing this as a duplicate of #4770 so we can focus the discussion there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants