flake8.extension entry point has global ramifications

Bug #1631156 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
High
Barry Warsaw

Bug Description

We have a flake8 extension for checking some aspects of our particular coding style. We do this using the upstream recommended way of adding an `entry_points` section:

https://flake8.readthedocs.io/en/latest/plugin-development/registering-plugins.html

The problem is that when we `apt install` the python3-ubuntu-image package, this sets up a global entry point for flake8. Then when flake8 runs, it cannot find the ubuntu_image/testing subpackage because that doesn't get installed during package build. And flake8 will traceback and fail.

I think there are several problems here:

* I use the ubuntu_image.testing.flake8 code in many projects, so it should be refactored and moved into a separate package.

* flake8 shouldn't fail hard when it has a problem loading an extension.

* Maybe ubuntu_image/testing should be included in the python3-ubuntu-image binary package.

* There should be some way to enable a "local" flake8 extension.

Revision history for this message
Barry Warsaw (barry) wrote :

For now the "solution" is to remove the python3-ubuntu-image package, but that's suboptimal.

Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: none → 0.9
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → High
status: New → In Progress
Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: 0.9 → none
Revision history for this message
Barry Warsaw (barry) wrote :

I believe this will be fixed with a switch to flufl.testing and the latest flake8 package. The latter has several fixes to the plugin infrastructure and the former does flake8 plugins correctly.

The downside is that flufl.testing isn't yet in Debian. See Debian bug #844650 for the ITP, which I'll work on soon. Of course that will mean we'll only be able to run the test suite in Zesty, so I'll have to also figure out workarounds for Yakkety and Xenial (possibly including not backporting these changes, although that will be fairly inconvenient).

Revision history for this message
Barry Warsaw (barry) wrote :

I just uploaded flufl.testing to Debian. I'm thinking once that clears NEW and makes it into Zesty, I'll backport it to Yakkety and Xenial and then switch ubuntu-image over to it.

Changed in ubuntu-image:
milestone: none → 0.13
Revision history for this message
Barry Warsaw (barry) wrote :

flufl.testing has cleared NEW and is in Zesty so the backports can be started. The ubuntu-image branch has been updated.

Revision history for this message
Barry Warsaw (barry) wrote :

After further discussion, we won't backport the new dependency to fix this problem. If it hits you, use the u-i snap or apt purge the deb when you need to run flake8.

Changed in ubuntu-image:
milestone: 0.13 → none
status: In Progress → Won't Fix
assignee: Barry Warsaw (barry) → nobody
Revision history for this message
Barry Warsaw (barry) wrote :

I'm reopening this since we had another user run into the same problem on Xenial.

I'm still not sure how to fix this across all three supported distro versions.

Changed in ubuntu-image:
status: Won't Fix → Confirmed
milestone: none → 1.0
assignee: nobody → Barry Warsaw (barry)
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Confirmed → In Progress
Revision history for this message
Barry Warsaw (barry) wrote :

I figured out a clever way to fix this. With a hack to the setup.py, the flake8 extension entry point only gets installed when an environment variable is set. We'll default to "off" and only enable it in the tox.ini. Since d/rules doesn't run tox and a normal `$python setup.py egg_info` (as pybuild runs) won't enable it, it won't get globally installed in the .deb

Barry Warsaw (barry)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
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.