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

[bazel, rules_python] Unable to get correct Python path from whl? #6930

Open
EricCousineau-TRI opened this issue Jul 17, 2024 · 5 comments
Open
Labels
🐍 Python API Python logging API

Comments

@EricCousineau-TRI
Copy link

EricCousineau-TRI commented Jul 17, 2024

Describe the bug
Relates bazelbuild/rules_python#2071

To Reproduce
See repro in linked issue, i.e,.
https://github.com/EricCousineau-TRI/repro/tree/e084a7434286cf426a71350f79755c7cbab6d6eb/bazel/rules_python_rerun

Workaround: EricCousineau-TRI/repro@96e1336

Expected behavior
Things are declared such that rules_python generates rules that have correct PYTHONPATH

Screenshots
N/A

Backtrace
N/A

Desktop (please complete the following information):

  • OS: Ubuntu 22.04

Rerun version
0.17.0

Additional context
using bazel build system + rules_python

@EricCousineau-TRI EricCousineau-TRI added 👀 needs triage This issue needs to be triaged by the Rerun team 🪳 bug Something isn't working labels Jul 17, 2024
@Wumpf
Copy link
Member

Wumpf commented Jul 18, 2024

I unfortunately don't know anything about Bazel build setups, but I suppose there's some issue about the package being called rerun-sdk, but the module is rerun?

@abey79
Copy link
Member

abey79 commented Jul 18, 2024

I know nothing about bezel, but I'm kind of surprised by that __init__.py file there. I dont have it when I manually install rerun in a venv:

$ ls external/pip_deps_rerun_sdk/site-packages/rerun_sdk
__init__.py  rerun  rerun_cli

Also, for records, this what I have in my site-packages:

…/lib/python3.11/site-packages 
❯ ls | grep rerun
rerun_bindings
rerun_sdk
rerun_sdk-0.17.0.dist-info
rerun_sdk.pth

You may want to check if you have that .pth in particular.

@EricCousineau-TRI
Copy link
Author

but I suppose there's some issue about the package being called rerun-sdk, but the module is rerun

yeah, I think that it's because the module is under rerun_sdk/{rerun,rerun_cli} as abey79 mentioned.

You may want to check if you have that .pth in particular.

yeah, it seems like rules_python may not correctly recognize .pth files:
bazelbuild/rules_python#2071 (comment)

closing this issue, as it seems like a bazel rules_python issue.
thanks!

@abey79
Copy link
Member

abey79 commented Jan 17, 2025

Reopening this issue, if only for visibility. Although this technically seems to be a Bazel problem, it's is triggered by some packaging trick we are doing using that pth file.

@abey79 abey79 added 🐍 Python API Python logging API and removed 👀 needs triage This issue needs to be triaged by the Rerun team 🪳 bug Something isn't working labels Jan 17, 2025
@jleibs
Copy link
Member

jleibs commented Jan 17, 2025

I'm kind of surprised our approach there has held up as long as it has. For context, the number one thing our .pth hackery exists to achieve is to save us from collateral damage being caused by the rerun package in pypi-managed environments.

Especially in the early days of Rerun it was very common for people to pip install rerun instead of pip install rerun-sdk. This wouldn't have been quite so bad in-and-of-itself, but we also felt strongly that import rerun was superior to import rerun_sdk.

In theory we CAN just install rerun as a top-level package, but if a user ever installs rerun package accidentally, the files stomp on each other and to get back in a clean state you have to uninstall rerun and then force-reinstall rerun-sdk. And since pypi provides no way of declaring a mutual exclusion with another package, there was no way to prevent this.

Scoping rerun as a sub-package of rerun_sdk and injecting it into the top-level package path via a .pth file keeps us from having any conflicting files, and avoiding the need for that reinstall.

We need some way to provide a target for bazel users that users an alternative layout that avoids the need for .pth files, under the assunption they won't be adding rerun to their projects.

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

No branches or pull requests

4 participants