Unbreak module imports for Python2
ClosedPublic

Authored by kossebau on Jan 14 2020, 8:33 AM.

Details

Test Plan

Using kapidox_generate with python3 & python2 works

Diff Detail

Repository
R264 KApiDox
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Jan 14 2020, 8:33 AM
Restricted Application added projects: Frameworks, Documentation. · View Herald TranscriptJan 14 2020, 8:33 AM
Restricted Application added subscribers: kde-doc-english, kde-frameworks-devel. · View Herald Transcript
kossebau requested review of this revision.Jan 14 2020, 8:33 AM

Why should Python 2 continue to be supported, after its EOL on 2020-01-01?

What cases would a user be running the latest KDE release, but still have a Python 2 interpreter present as their primary/only Python interpreter?

kossebau added a comment.EditedJan 14 2020, 9:06 AM

Because the very user api.kde.org right now in production still uses python2 sadly (edit: see comments on D25632 for how i fails). And replacing that server with something modern is sadly not a few-hours job, still waiting for someone to spend the weeks on getting a substitution done.

bcooksley added inline comments.
src/kapidox/depdiagram/frameworkdb.py
39

This probably needs to be import gvutils from kapidox.depdiagram otherwise any calling code will need to be kapidox.depdiagram.gvutils.<whatever> instead of just fvutils.<whatever> (unless Python3 allows something special i'm not aware of)

kossebau added inline comments.Jan 14 2020, 9:28 AM
src/kapidox/depdiagram/frameworkdb.py
39

As said no Python developer myself, but the code using the import is like this a few times below:

for node_handle in gvutils.get_node_list(src_handle):
    node = gvutils.Node(node_handle)

so something there seems to work? Also this is the current import code added in D25632 to have it work with Python3, so my expectation would have rather been this is correct?

To add to my confusion, running the unpatched version works with my local 2.7.17 python interpreter (checked with print (sys.version)) and worse, running things manually on api.kde.org in some test subdir also works with its 2.7.15...

Now why does it fail in the cronjob...

For now, given @bcooksley's comment going to try some simple change to 'from kapidox.depdiagram import gvutils', this is a pattern found elsewhere in the old code. Will do a local patch to the checkout on the server and see if this has any effect on next cron job run. So far that also worked for all the 3 situations I tested (local python3 & python2, python2 on server test env).

All that while awaiting Python gurus to bring in the light :)

kossebau updated this revision to Diff 73513.Jan 14 2020, 12:01 PM

Brown paper bag for me: if one changes code, they should also see to trigger
that code, in this case passing the --depdiagram-dot-dir arg to
kapidox_generate...

I can confirm now in my testing on the server that things fail without the
patch, and work with this simple change Ben hinted to :)

Last night's run of api.kde.org generation with kapidox locally patched with this change worked again,
So unless there are objections will push then latest next WE, though happy to have people give green light before :)

davidedmundson accepted this revision.Jan 15 2020, 8:44 AM
This revision is now accepted and ready to land.Jan 15 2020, 8:44 AM
This revision was automatically updated to reflect the committed changes.