Fix pacgraph-tk regression for Python 3.12#13
Open
ekorchmar wants to merge 2 commits intokeenerd:masterfrom
Open
Fix pacgraph-tk regression for Python 3.12#13ekorchmar wants to merge 2 commits intokeenerd:masterfrom
ekorchmar wants to merge 2 commits intokeenerd:masterfrom
Conversation
Introduces a fork in import logic depending on version, choosing different manual import mechanic
Just in case it will be important in the future
pokulo
reviewed
Jun 18, 2024
| if not dev: | ||
| import imp | ||
| imp.load_source('pacgraph', '/usr/bin/pacgraph') | ||
| import pacgraph |
There was a problem hiding this comment.
If dev = True is set to enable developement mode, import pacgraph from local folder should work. This MR moves all the importing of pacgraph into the if not dev: branch. Which renders the development mode broken (with no import).
Instead of hard coding the dev mode, we could first try to import pacgraph locally and catch the ImportError and only then attempt to do the import magic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue #12.
Backstory
CPython's
impmodule was considered deprecated since 3.4, and was completely removed at 3.12;importlibshould be used instead. As of right now, Python 3.12 is the default Arch package, so pacgraph-tk is de facto broken out of the box.Relevant links
Changes
Added a conditional fork to import necessary package using
importlibrather thanimpfor Python versions >= 3.12. Code was written in a way to as not to introduce syntax that would not be understood by earlier Python versions (e.g. installed manually or from AUR).Testing
Manually tested on ArchLinux with default Python installation.
References