-
Notifications
You must be signed in to change notification settings - Fork 10
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
pth: Add a add_pth
option to py_pyenv.
#14
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not seeing this sooner.
pth
files were actually my first approach, but I found that PyCharm didn't pick up on changes under the paths pointed to by the pth
file, which is why I instead resorted to symlinking everything. If tools worked as expected, pth files would certainly be much more straightforward. That said, it seems like something that we could support optionally, as you are here.
venv.bzl
Outdated
@@ -24,6 +24,7 @@ def _py_venv_deps_impl(ctx): | |||
for dep in ctx.attr.deps: | |||
if PyInfo not in dep: | |||
continue | |||
print(dep[PyInfo].imports.to_list()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a leftover debug statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, whoops!
for file in files: | ||
if is_data_file(file): | ||
install_data_file(env_path, file) | ||
else: | ||
install_site_file(site_packages_path, file) | ||
if add_pth: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're creating a pth
file, do we still need to call install_site_file
? Isn't that redundant?
Hm, I didn't test using pycharm, I was testing using VSCode. Unfortunately, I don't have access to pycharm. |
Currently, rules_pyvenv installs all the python deps by symlinking them in site-packages. However, in bazel, the python deps are actually added to the PYTHONPATH, which means that for some deps, just symlinking into site-packages doesn't work. However, venv supports this via pth files. pth files will append the directories specified in the pth file to the PYTHONPATH, which exhibits the behavior we want. Fixes cedarai#13
Currently, rules_pyvenv installs all the python deps by symlinking them in site-packages. However, in bazel, the python deps are actually added to the PYTHONPATH, which means that for some deps, just symlinking into site-packages doesn't work.
However, venv supports this via pth files. pth files will append the directories specified in the pth file to the PYTHONPATH, which exhibits the behavior we want.
Fixes #13