-
-
Notifications
You must be signed in to change notification settings - Fork 591
pip_parse()
does not correctly read *.pth
files?
#2071
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
Comments
imports
and deps
via package_annotation
imports
and deps
via package_annotation
?
|
in this case, it's missing perhaps it's because there's a $ cd $(bazel info output_base)
$ cat external/pip_deps_rerun_sdk/site-packages/rerun_sdk.pth
rerun_sdk from docs https://docs.python.org/3/library/site.html |
(if this seems like a valid thing, I can |
Thanks for the repro and the logs, this makes it easier to understand. The I think ideally the solution would be to investigate how to make |
imports
and deps
via package_annotation
?pip_parse()
does not correctly read *.pth
files?
sweet, welcome I think simplest way is to assume it's non-executable would probably need something like |
very loose code: main...EricCousineau-TRI:rules_python:issue-2071 |
This looks like it could work, having such code in whl_library could be a good idea.
If you would like to finish this and submit a PR, feel free to do it. I think the main idea of just reading the pth file in starlark and then appending the imports would be a nice way to do it.
…On 20 July 2024 03:01:02 GMT+09:00, Eric Cousineau ***@***.***> wrote:
very loose code: main...EricCousineau-TRI:rules_python:issue-2071
--
Reply to this email directly or view it on GitHub:
#2071 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
Closing this issue as a duplicate of #2156 Any PR to workaround |
With Python 3.12,
With this in mind, I don't think that reading the pth file in starlark and appending the imports would work. It might work for some packages, but not for At our company, we're using a workaround where we create a |
I think the issue is that there can be only one Is |
In this case, import distutils as _distutils In Python 3.11 and earlier, this is an import from the standard library, so we're not really involving
|
I am somewhat thinking that setuptools should be treted in rules_python in a special way. I have no other ideas on how to fix this - maybe we coud have a special BUILD.bazel file for that package and reuse the same setuptools repository everywhere. If the user tries to include it via pip in bzlmod, we could easily handle that. Doing that in workspace may be too much work. Potentially related - #2370 |
If we want to treat setuptools in a special way, one possible way forward is to bundle it with the Python installation itself, which
For reasons unknown to me, it's no longer bundled with Python 3.12:
If we were to do a special BUILD.bazel file for setuptools, what would we do in that? I see a few ways setuptools can be handled in a way that respects the |
@aignas I still believe it's more closely related to #2156 (which is why I marked it as duplicate). pth files are a runtime hook based on site-packages and site.py, it's not really a setuptools/distutils thing (but distutils is using a pth file as a deprecation mechanism). A workaround in the meantime for the runtime distutils -> setuptools change in 3.12 (distutils is now finally fully deprecated) is to patch any packages still using distutils to pull in a runtime version of setuptools. |
I see what you mean @groodt by saying that this ticket is a duplicate of #2156 and me re-opening this is only because I think that That said, I like what you suggest - patch the wheels, or submit upstream patches to patch the source to drop distutils dependence. |
🚀 feature request
Relevant Rules
package_annotation()
frompip.bzl
Description
From docs, as of time of writing, you can add
BUILD
content, or add / remove files, but doesn't seem like you can changepy_library(deps, imports)
.For example, rerun.io is an awesome-looking package.
But it doesn't work when using using bazel +
rules_python @ 0.34.0
:https://github.com/EricCousineau-TRI/repro/tree/e084a7434286cf426a71350f79755c7cbab6d6eb/bazel/rules_python_rerun
Seems like either the wheel doesn't declare things s.t.
rules_python
adds./site-packages/rerun_sdk
to the Python path (it only adds./site-packages
).Describe the solution you'd like
For now, would be nice to have something like
Describe alternatives you've considered
For now, will try
package_annotation(..., additive_build_content)
, and include that whenever I usepip("rerun-sdk")
.EDIT: This workaround worked: EricCousineau-TRI/repro@96e1336
The text was updated successfully, but these errors were encountered: