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

charmhelpers.fetch.python.pip_install fails to install libraries when targeting a virtual environment depending on PYTHONPATH #607

Open
jguedez opened this issue May 14, 2021 · 0 comments
Labels

Comments

@jguedez
Copy link

jguedez commented May 14, 2021

In certain cases when installing packages using pip_install with a PYTHONPATH environment variable set it can fail to install the package. An example of that is when using a charm with the operator framework, which already has a venv. If that venv already has a library installed in it (e.g pyyaml), invoking pip_install using a virtual environment will fail to install it. Pip will consider the library to be installed already since it can find it in the PYTHONPATH (even though it's actually not installed in the venv provided). An example of this situation with all the details can be found in [0]

In this case it would probably be best to ignore any PYTHONPATH so pip will install the requested libraries in the target virtual environment if they are not installed there already. Another option would be to accept an env parameter and pass it to the subprocess call.

It would also help to use check_output instead of check_call, at least at debug level so the logs can show what is actually happening in unexpected situations like this.

[0] https://bugs.launchpad.net/charm-juju-lint/+bug/1928337
[1] https://github.com/juju/charm-helpers/blob/master/charmhelpers/fetch/python/packages.py#L112

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

No branches or pull requests

2 participants