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

PyO3 always retriggers compilation when used with IDE/Shell combination. #1229

Closed
nikhilmitrax opened this issue Oct 11, 2020 · 2 comments · Fixed by #1231
Closed

PyO3 always retriggers compilation when used with IDE/Shell combination. #1229

nikhilmitrax opened this issue Oct 11, 2020 · 2 comments · Fixed by #1231

Comments

@nikhilmitrax
Copy link

nikhilmitrax commented Oct 11, 2020

🐛 Bug Reports

When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.

🌍 Environment

  • Your operating system and version: Linux, MacOS
  • Your python version: 3.6, 3.7,3.8
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: Pyenv and system native (Ubuntu)
  • Your Rust version (rustc --version): nightly-2020-07-11
  • Your PyO3 version: 0.11.1, 0.9.2
  • Have you tried using latest PyO3 master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?: No

💥 Reproducing

Any PyO3 code should face the same behaviour.

Hello,

Thank you very much for the PyO3 project. This has been a massive game changer in accelerating python based projects. I noticed that PyO3 was triggering recompilation (or rechecking) after every change I made, even if the change was in an unrelated crate.

The source was found out to be rust-analyzer running in the IDE, where, due to many factors, the PATH can be different than in the shell. Under certain other environments, the PATH can be different between two shells as well. (Something like fnm uses PATH to set the node versions, changing the variable). I'm not certain, but IDEs such as VSCode also modify PATH before executing.

All of this makes for a very excruciating development environment, especially in very large projects where PyO3 based code is a relatively static and small part of the codebase. We've resorted to using a forked version with the PATH rechecking disabled, but I thought I should still file the bug since other people may also have the same issue.

I understand the need for checking PATH to trigger recompilation, but I was wondering if there was an alternative for situations where the PATH is expected to change unrelated to the location of the python executable. My build.rs knowlege is a bit lacking, but I was wondering if this would be solved by adding a cargo feature flag or something.

Once again, thank you so much for the time you've put into PyO3.

@davidhewitt
Copy link
Member

Hi @nikhilmitrax thanks for reporting.

We need to use PATH to find the python executable, as you noted. However I think when PYO3_PYTHON is an absolute path to an interpreter, then we don't need to rely on PATH and could ignore changes to it. Would this be acceptable for you? The expectation would be that you set this in all environments where you're compiling code.

If so, I'll add a tweak to build.rs tonight which we can release with pyo3 0.12.2.

@nikhilmitrax
Copy link
Author

That makes total sense.

Let me know if you need any assistance with this. I could help coding this up or testing this out.

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

Successfully merging a pull request may close this issue.

2 participants