Map remote sources to local files in PyCharm

I am using PyCharm 2022.2 (Professional Edition). I have set up a remote Docker Compose interpreter - code executes as expected, I can run all tests from withing the IDE, external libraries toggle contains all skeletons, extended definitions and remote libraries.

The problem is the remote libraries. They're all sourced from local directory called `lib` that sits in the project's root folder, and I'm mapping them to the interpreter via docker compose volumes. As I wrote above, they show correctly in the libraries and I can run any code that uses them without errors.

When I navigate from another service to one of the library files with Ctrl+click, I would expect to go directly to the local version of that file. Sadly, PyCharm throws me to the external definition and so when I want to change one of the library files, to get an immediate feedback in my hot-reloaded service, I have to first find the file within my project tree.

Because of how frustrating this is, I am convinced that there is a solution that will allow me map the external libraries to their local versions and tell PyCharm to Ctrl+click navigate to those. Can someone help?

 

1 comment
Comment actions Permalink

Hi,  I tried reproducing the issue in a simple project but wasn't successful. I mounted a module to the container using run/debug configuration's container settings, added the mounted directory to the PYTHONPATH (again, using the run/debug configuration), and made sure the module is imported successfully. Then, going to declaration on the function call from the module navigates me to the local file (not remote sources) as expected.

I assume your setup may be different and if I replicated it, I would reproduce the issue. What I suggest to do is to submit an issue to our tracker at https://youtrack.jetbrains.com/issues/py with a small project sample and the steps to reproduce the issue. We'll take a look and if there's a workaround, it will be suggested to you. If not, then the issue will stay open and will be tracked for further actions.

1

Please sign in to leave a comment.