rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

eBPF tracing support for python runtime installed using bazel

Open hariom-qure opened this issue 1 year ago • 2 comments

🚀 feature request

Relevant Rules

My workspace file looks like this

### PYTHON
http_archive(
    name = "rules_python",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()


# use hermetic / bundle python3.9
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
    name = "python3_9",
    python_version = "3.9",
    register_coverage_tool = True
)

load("@python3_9//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
    name = "python_deps",
    python_interpreter_target = interpreter,
    requirements_lock = "//third_party/python:requirements_lock.txt",
)

# Load the starlark macro which will define your dependencies.
load("@python_deps//:requirements.bzl", "install_deps")

Description

I want to use eBPF to instrument my application.

Describe the solution you'd like

Its possible to use eBPF if this URL is followed for building python https://docs.python.org/3/howto/instrumentation.html In addition to this, having frame pointer is also useful, python needs to be built with the -fno-omit-frame-pointer option

hariom-qure avatar Jan 31 '24 07:01 hariom-qure

Right now we are not building our own toolchains and we use https://github.com/indygreg/python-build-standalone. This feature request either requires an upstream ask or supporting building CPython ourselves using a cc toolchain.

aignas avatar Feb 02 '24 04:02 aignas

We discussed this some time ago in the maistainers meeting and so far there was no interest or resources to build our own python interpreter.

However, you should be able to build it and register the new toolchain in a similar way how existing toolchains are registered.

Feel free to create an issue in the upstream toolchain project.

aignas avatar Mar 13 '24 11:03 aignas