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

How to set PYTHONPATH for python shell based on project root? #91

Open
orlandini opened this issue Mar 5, 2024 · 0 comments
Open

How to set PYTHONPATH for python shell based on project root? #91

orlandini opened this issue Mar 5, 2024 · 0 comments

Comments

@orlandini
Copy link

Hello,
I am using pyright and I am currently able to detect my (sub)project root by means of a .projectile file in the desired directory.
In this way, pyright finds all my modules as expected.

Now, I would like to start a python shell with the project root directory prepended to my existing PYTHONPATH.

I've found a way to change the working directory of the python interpreter:

(defun my-run-python ()
  (interactive)
  (let ((default-directory (or (projectile-project-root) default-directory)))
    (call-interactively #'run-python)))

However, this is not the behaviour I intended. I just would like to prepend (projectile-project-root) to the PYTHONPATH seen by the python interpreter when called through run-python whenever I am in a project using pyright. Perhaps using lsp-pyright-extra-paths would be useful, but I am not an expert in Lisp.

Best regards and thank you in advance,

Francisco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant