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

DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses #1517

Closed
markblundeberg opened this issue Jul 14, 2019 · 7 comments · Fixed by #2020
Assignees
Labels
backlog Nits / Refactoring PRs and issues related to things like code formatting and small nits packaging Issues related to building/packaging and not the app itself. WantWantWant Stuff we really want to do but there blocking issues and/or it will take time

Comments

@markblundeberg
Copy link
Collaborator

As of Python 3.7 or thereabouts, we get this warning on startup:

./electron-cash:96: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

# load local lib etc modules as electroncash*
if is_local:
import imp
imp.load_module('electroncash', *imp.find_module('lib'))
imp.load_module('electroncash_gui', *imp.find_module('gui'))
imp.load_module('electroncash_plugins', *imp.find_module('plugins'))

It's a bit annoying to refactor these lines using importlib because we rename the modules.

@markblundeberg
Copy link
Collaborator Author

@cculianu
Copy link
Collaborator

Hmm... so this isn't immediately refactorable? Let me read the importlib docs and see if we can do something... :/

Yet more reasons to switch away from this rewriting of the import paths thing...

@cculianu cculianu self-assigned this Jul 14, 2019
@cculianu cculianu added Nits / Refactoring PRs and issues related to things like code formatting and small nits packaging Issues related to building/packaging and not the app itself. labels Jul 14, 2019
@markblundeberg
Copy link
Collaborator Author

I'm sure there's a way, just not immediately obvious.

@cculianu
Copy link
Collaborator

cculianu commented Jul 14, 2019

Yeah I just tried hacking away at it -- not immediately obvious to me either. The python docs to importlib and importlib.util come with a bunch of recipes and examples but none of them really works to do what we want. Will look into this more...

The real solution is to just do away with this hacky rewriting of dirs... but it requires going into all the build scripts and other assorted odds and ends and making sure they don't break... so it's an annoying task.. :/

@markblundeberg
Copy link
Collaborator Author

markblundeberg commented Jul 14, 2019

Worth noting: recent discussion on deprecation schedules suggests python 3.10 will be the first to have imp removed, so we have quite some time to deal with this.

https://www.python.org/dev/peps/pep-0594/#imp

Given 3.8 and 3.9 release schedules, we could guess that 3.10 will come out in March 2021. Hard to say for sure, could be much later than that.
https://www.python.org/dev/peps/pep-0569/#schedule
https://www.python.org/dev/peps/pep-0596/#schedule

@cculianu
Copy link
Collaborator

cculianu commented Jul 14, 2019

Ah coo. Thanks for the info.

Well, given that we are still on 3.6 officially -- and even the odd person won't be installing 3.10 until 2021 at the earliest -- I'll backlog this. This is more a nit than anything -- it would be nice to remove the imp module stuff altogether but it's annoying little work that takes like 4 hours to get right and test.

@cculianu cculianu added backlog WantWantWant Stuff we really want to do but there blocking issues and/or it will take time labels Jul 14, 2019
@cculianu cculianu changed the title DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses See about doing away with the lib/, gui/, etc dirs and just name them "electroncash" "electroncash_gui", etc, directly Jul 14, 2019
@cculianu cculianu changed the title See about doing away with the lib/, gui/, etc dirs and just name them "electroncash" "electroncash_gui", etc, directly DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses Jul 14, 2019
@mhsmith
Copy link
Collaborator

mhsmith commented Jul 25, 2019

See also #807.

@mhsmith mhsmith linked a pull request Oct 18, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Nits / Refactoring PRs and issues related to things like code formatting and small nits packaging Issues related to building/packaging and not the app itself. WantWantWant Stuff we really want to do but there blocking issues and/or it will take time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants