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

use different venv during local development and during cicd #214

Closed
copdips opened this issue Sep 26, 2023 · 9 comments
Closed

use different venv during local development and during cicd #214

copdips opened this issue Sep 26, 2023 · 9 comments

Comments

@copdips
Copy link

copdips commented Sep 26, 2023

Hello,

I'm using pyright by is public github action. and I see that pyright has a param venv which can specify the venv path, I would like to know that, during the local development, I use venv, it's OK. But during the CICD, I don't use venv, just install everything at system level, in such case, how to keep a single pyproject.toml but with different venv ?
Does pyright support find automatically the package installation path based on python executable used.
It seems that mypy can do that, we do not need to specify which venv to use, just run mypy

@copdips copdips changed the title use different venv when local and during cicd use different venv during local development and during cicd Sep 26, 2023
@ryanpeach
Copy link

Same

@RobertCraigie
Copy link
Owner

For most use cases you shouldn't need to explicitly specify a virtual environment path, you can instead activate your environment before running pyright and it will be picked up automatically.

@RobertCraigie RobertCraigie closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
@copdips
Copy link
Author

copdips commented Sep 23, 2024

For most use cases you shouldn't need to explicitly specify a virtual environment path, you can instead activate your environment before running pyright and it will be picked up automatically.

Hello @RobertCraigie

Thank you for taking the time to reply to this issue.
However, I believe there might be a misunderstanding.
The reason I raised this issue is that Pyright installed from the repository cannot automatically detect the virtual environment (venv), and you provided a workaround by suggesting the use of the venv parameter in the pyproject.toml file.

Hereunder the guideline in the README.md:

image

@copdips
Copy link
Author

copdips commented Sep 23, 2024

And the reason I use Pyright installed from the repository and not from pip install pyright is that sometimes in CICD only Pyright doesn't work due to a 'file not found' error."

And I saw an issue and this issue discussing a race condition, is it related ?

@RobertCraigie
Copy link
Owner

Ah I see, you're specifically talking about pre-commit. Sorry for the misunderstanding.

I'm not sure if there's a great solution here unfortunately, I'm also not familiar with pre-commit anymore as I stopped using it years ago.

Would adding your dependencies to the pre-commit config work for you? https://pre-commit.com/#config-additional_dependencies

@RobertCraigie
Copy link
Owner

ah @copdips maybe this would be helpful? #203 (comment)

@copdips
Copy link
Author

copdips commented Sep 23, 2024

adding your dependencies

adding deps in pyright pre-commit conf requires us to declare them in 2 places, which I don't feel confortable with...

@copdips
Copy link
Author

copdips commented Sep 23, 2024

ah @copdips maybe this would be helpful? #203 (comment)

Thanks a lot, I didn't know pyright also has --pythonpath parameter.
This will definitely help, I will try using sys.executable first instead of os.path.realpath(sys.executable), as realpath reflects the system-level Python path, but not the one in venv.

@RobertCraigie
Copy link
Owner

adding deps in pyright pre-commit conf requires us to declare them in 2 places, which I don't feel confortable with...

oh there's no way to specify a requirements.txt or similar with pre-commit? would probably be worth filing a feature request with pre-commit if there isn't an existing one already

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

3 participants