tox -epep8 fails due to tox picking python 3.x

Bug #1456955 reported by Endre Karlson
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Designate
Fix Released
Medium
Endre Karlson
OpenStack Compute (nova)
Fix Released
Low
Sean Dague
Liberty
Fix Released
Undecided
Unassigned

Bug Description

karlsone@workstation:~/projects/dnsaas/designate$ tox -epep8
pep8 create: /home/karlsone/projects/dnsaas/designate/.tox/pep8
pep8 installdeps: -r/home/karlsone/projects/dnsaas/designate/requirements.txt, -r/home/karlsone/projects/dnsaas/designate/test-requirements.txt
pep8 develop-inst: /home/karlsone/projects/dnsaas/designate
pep8 runtests: PYTHONHASHSEED='0'
pep8 runtests: commands[0] | flake8
Traceback (most recent call last):
  File ".tox/pep8/bin/flake8", line 9, in <module>
    load_entry_point('flake8==2.1.0', 'console_scripts', 'flake8')()
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/flake8/main.py", line 24, in main
    flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG)
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/flake8/engine.py", line 79, in get_style_guide
    kwargs['parser'], options_hooks = get_parser()
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/flake8/engine.py", line 53, in get_parser
    parser_hook(parser)
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/hacking/core.py", line 146, in add_options
    factory = pbr.util.resolve_name(local_check_fact)
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/pbr/util.py", line 171, in resolve_name
    ret = __import__('.'.join(module_name), fromlist=[attr_name])
  File "/home/karlsone/projects/dnsaas/designate/designate/__init__.py", line 16, in <module>
    import eventlet
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/__init__.py", line 10, in <module>
    from eventlet import convenience
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/convenience.py", line 6, in <module>
    from eventlet.green import socket
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/green/socket.py", line 17, in <module>
    from eventlet.support import greendns
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/support/greendns.py", line 54, in <module>
    socket=_socket_nodns)
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/patcher.py", line 119, in import_patched
    *additional_modules + tuple(kw_additional_modules.items()))
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/eventlet/patcher.py", line 93, in inject
    module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/dns/resolver.py", line 32, in <module>
    import dns.flags
  File "/home/karlsone/projects/dnsaas/designate/.tox/pep8/lib/python3.4/site-packages/dns/flags.py", line 51, in <module>
    _by_value = dict([(y, x) for x, y in _by_text.iteritems()])
AttributeError: 'dict' object has no attribute 'iteritems'
ERROR: InvocationError: '/home/karlsone/projects/dnsaas/designate/.tox/pep8/bin/flake8'
____________________________________________________________________________________________________________________________________ summary _____________________________________________________________________________________________________________________________________
ERROR: pep8: commands failed

Changed in designate:
assignee: nobody → Endre Karlson (endre-karlson)
status: New → In Progress
Changed in designate:
milestone: none → liberty-1
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to designate (master)

Reviewed: https://review.openstack.org/184049
Committed: https://git.openstack.org/cgit/openstack/designate/commit/?id=17858534b3e9bbaf3a224d7faec2c66ef0070a65
Submitter: Jenkins
Branch: master

commit 17858534b3e9bbaf3a224d7faec2c66ef0070a65
Author: Endre Karlson <email address hidden>
Date: Mon May 18 15:16:25 2015 +0200

    Pin python version to 2.7

    Make python versioned pinned to 2.7, if it's not pinned newer OS's will pickup
    3.x instead for tox env's.

    Closes-Bug: #1456955

    Change-Id: I5312206aaf83857a56a75cc24d3b56322a74420c

Changed in designate:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in designate:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in designate:
milestone: liberty-1 → 1.0.0
Alvaro Lopez (aloga)
no longer affects: nova (Ubuntu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/273613

Changed in nova:
assignee: nobody → Alvaro Lopez (aloga)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Alvaro Lopez Garcia (<email address hidden>) on branch: master
Review: https://review.openstack.org/273613

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/275182

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/275183

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/275184

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/275185

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/275186

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/275187

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/275183
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=216c98888e3eebbc630d7de3799bd3cd364abd5c
Submitter: Jenkins
Branch: master

commit 216c98888e3eebbc630d7de3799bd3cd364abd5c
Author: Alvaro Lopez Garcia <email address hidden>
Date: Tue Feb 2 10:53:42 2016 +0100

    Do not use "file" builtin, but "open" instead

    In Python 2 there is a file type builtin, but this is not the case for
    Python 3. Replace it with "open" where possible, and replace with a
    StringIO when we are mocking an output file.

    Partial-Bug: #1456955
    Change-Id: Ifcfed3865c41f1e772fda3717736aead713b37d6

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/275182
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0eebaa01f8eb0adc8a999126bc3deeb47614838c
Submitter: Jenkins
Branch: master

commit 0eebaa01f8eb0adc8a999126bc3deeb47614838c
Author: Alvaro Lopez Garcia <email address hidden>
Date: Tue Feb 2 10:30:09 2016 +0100

    xrange() is renamed to range() in Python 3

    Change-Id: I423dd4ce36759e3dc482e66fb743358f467069ef
    Partial-Bug: #1456955

Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

So, I just blocked https://review.openstack.org/#/c/275185/3 because I feel it's wrong to modify the code itself for trying to support both python versions.

By looking at the bug report, I'd rather be in favor of understanding the problem with running tox -epep8 on the nova code. Is that because you're running on a machine with only python3 supported ?

Changed in nova:
status: In Progress → Incomplete
importance: Undecided → Low
Revision history for this message
John Garbutt (johngarbutt) wrote :

This really does feel like it should be part of this effort, rather than a bug: https://blueprints.launchpad.net/nova/+spec/nova-python3-mitaka

Revision history for this message
Alvaro Lopez (aloga) wrote :

Sorry I missed the comments in this bug report.

The failures that were originally reported were caused by tox choosing python3
as the default version for running pep8 tests in newer systems. This is
happening for instance in Debian 8 systems, where one cannot simply run
"tox -epep8", as it fails:

    $ tox -epep8
    (...)
    Running flake8 on all files
    ./nova/virt/xenapi/volume_utils.py:59:48: F821 undefined name 'unicode'
    ./nova/pci/stats.py:301:16: F821 undefined name 'cmp'
    ./plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:119:31: E901 SyntaxError: invalid syntax
    ./plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py:76:26: E901 SyntaxError: invalid syntax
    ./plugins/xenserver/networking/etc/xensource/scripts/vif_rules.py:126:14: E211 whitespace before '('
    ./plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py:46:20: E901 SyntaxError: invalid syntax
    ./plugins/xenserver/networking/etc/xensource/scripts/ovs_configure_vif_flows.py:230:14: E211 whitespace before '('
    ./tools/regression_tester.py:65:14: E211 whitespace before '(' ERROR: InvocationError: '/bin/bash tools/flake8wrap.sh'
    ___________________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________________
    ERROR: pep8: commands failed

If we pin the python version to python2.7 for the pep8 tests, it works
properly. Therefore my original submission was just forcing pep8 to run
using python2.7, but as Kevin suggested in the review, I substituted the
original patch and fixed the Py3 errors, that is why I did not add it to
https://blueprints.launchpad.net/nova/+spec/nova-python3-mitaka

Changed in nova:
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/282590

Changed in nova:
assignee: Alvaro Lopez (aloga) → Sean Dague (sdague)
Revision history for this message
Sean Dague (sdague) wrote :

Yeh, somehow this bug got turned into a generic python3 bug. That's not what this is. this is a very simple tox fix.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/282590
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=05583d14966a366f0d37753b81c8f72c87126348
Submitter: Jenkins
Branch: master

commit 05583d14966a366f0d37753b81c8f72c87126348
Author: Sean Dague <email address hidden>
Date: Fri Feb 19 21:10:42 2016 -0500

    always use python2.7 for pep8

    pep8 doesn't work with python3 on our codebase. If someone is on a
    platform that defaults to python => python3, pep8 won't work for
    them. This is actually really easy to fix with a single line in tox.

    Change-Id: I7a888e4f7cc828638a9d61d2249a854ba1f3cb7b
    Closes-Bug: #1456955

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 13.0.0.0b3

This issue was fixed in the openstack/nova 13.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Alvaro Lopez Garcia (<email address hidden>) on branch: master
Review: https://review.openstack.org/275187
Reason: This has been fixed in https://review.openstack.org/#/c/282590/ (same change as https://review.openstack.org/#/c/273613/ that was not merged :-( )

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Alvaro Lopez Garcia (<email address hidden>) on branch: master
Review: https://review.openstack.org/275186
Reason: This has been fixed in https://review.openstack.org/#/c/282590/ (same change as https://review.openstack.org/#/c/273613/ that was not merged :-( )

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Alvaro Lopez Garcia (<email address hidden>) on branch: master
Review: https://review.openstack.org/275185
Reason: This has been fixed in https://review.openstack.org/#/c/282590/ (same change as https://review.openstack.org/#/c/273613/ that was not merged :-( )

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Alvaro Lopez Garcia (<email address hidden>) on branch: master
Review: https://review.openstack.org/275184
Reason: This has been fixed in https://review.openstack.org/#/c/282590/ (same change as https://review.openstack.org/#/c/273613/ that was not merged :-( )

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.