Closed wookayin closed 9 months ago
/cc @justinmk @farisachugthai
BTW CI fails on 3.12 so I didn't include the commit https://github.com/wookayin/pynvim/compare/fix-import...wookayin:pynvim:ci-py312 in this PR. No idea why it fails to find the python3 host when python 3.12 is installed in the runner (py3.11 works fine). Possibly related to #528.
Also fails on windows but this PR is not accountable.
Huge thanks, this is tricky, especially the tests.
Also fails on windows but this PR is not accountable.
Yep known issue: https://github.com/neovim/pynvim/pull/526#issuecomment-1636349839 (we had no CI at all for awhile before that 😅 ).
BTW CI fails on 3.12 so I didn't include the commit wookayin/pynvim@fix-import...wookayin:pynvim:ci-py312 in this PR. No idea why it fails to find the python3 host when python 3.12 is installed in the runner (py3.11 works fine). Possibly related to #528.
Yes that's the other remaining mystery.
The removal of
imp
package (#461) in order to supprot Python 3.12 had a bug where rplugins can't be loaded and the ImportError exception was silenced, making the remote provider throwing lots of errors. This commit fixes broken dynamic import of python modules from the registered rplugins.We add tests for Host._load, with loading rplugins consisting of:
(1) single-file module (e.g.,
rplugins/simple_plugin.py
) (2) package (e.g.,rplugins/mymodule/__init__.py
)Note: As per https://docs.python.org/3.12/whatsnew/3.12.html#imp, I also tried something like:
but this fails to resolve relative import within the package to unlike the previous implementation using
imp
(see the unit test fixtures). Possible more addition ofloader
would be needed. If you think this is the right way, please let me know so we can have additional work. Actually the remote host python should be able to import packages, so I don't see any reason why we couldn't use the approach of manipulatingsys.path
and import the module.