-
Notifications
You must be signed in to change notification settings - Fork 543
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
Expose libpython from toolchain like interpreter
#2262
Comments
I could use that in my custom rule alongside the toolchain itself, but I was thinking that this might make sense as an attribute on the toolchain. To be more concrete my rule looks like this: def _impl(ctx):
...
transitive_runfiles = [
ctx.runfiles(files = py_toolchain.py3_runtime.files.to_list()),
]
libpython = None
for file in py_toolchain.py3_runtime.files.to_list():
if file.basename.startswith("libpython"):
libpython = file.short_path
# if there are multiple any of them should work and they are likely symlinks to each other
break
if not libpython:
fail("Failed to find libpython")
return [
DefaultInfo(executable = ...),
RunEnvironmentInfo(
environment = {"PYTHON_LIBRARY": libpython},
),
]
foo = rule(
implementation = _impl,
toolchains = [
"@bazel_tools//tools/python:toolchain_type",
],
executable = True,
) |
Curious -- why do you need to pass the path via an environment variable? To setup LD_LIBRARY_PATH later or something? (I can't recall -- I think you were one of the people doing embedded Python?) |
Our case is pretty unique, this is with the mojo programming language which offers python interop, so I need to tie together the actual python toolchain we want it to use by providing it through the env |
Currently if you're writing custom rules that depend on python, it can be useful to extract things from the underlying python toolcahin like
toolchain.py3_runtime.interpreter
. I think it would be useful to also be able to extract thelibpython
that is included in the toolchain in a similar way, which would be useful for linking to binaries in custom rules, or providing through env vars at runtime. The library is already accessible if you search through the files on the runtime, but being able to access it in a more structured way would be useful for this case.Thoughts?
The text was updated successfully, but these errors were encountered: