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

Better way to detect tools' path #919

Open
fannheyward opened this issue Apr 20, 2023 · 2 comments
Open

Better way to detect tools' path #919

fannheyward opened this issue Apr 20, 2023 · 2 comments

Comments

@fannheyward
Copy link
Owner

fannheyward commented Apr 20, 2023

Couldn't the logic be something like this? If pythonPath has been resolved to something in a virtualenv (e.g. .venv/bin/python). Store const venvBinPath = path.dirname(pythonPath). And then when running mypy you first try path.join(venvBinPath, 'mypy'). And if that fails, look in $PATH?

You could maybe even do that logic during startup and save the absolute path to the binary so you don't have to run a subprocess twice in the global case.

Originally posted by @lithammer in #917 (comment)

@fannheyward
Copy link
Owner Author

fannheyward commented Apr 20, 2023

Currently steps:

  1. get tool's path from setting, execPath = mypy
  2. use which to get full exec path
    • execPath = /full/path/to/global/mypy
    • or execPath = /path/to/project/.venv/bin/mypy
  3. now basename never equal to execPath, module name is undefined
  4. run in sub process mode, /full/path/to/mypy xxx

This detection can use global and local tools, but breaks module mode.

@fannheyward
Copy link
Owner Author

Another issue #901, rope can only be run in module mode, the detected Python bin must install rope to use.

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