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
[wip] pythonPackages.bcc-python: init at 0.5 #41196
Conversation
Add bcc python bindings (https://github.com/iovisor/bcc), aka tools to play with BPF and kernel.
I also did this here: https://github.com/NixOS/nixpkgs/pull/40426/files :) |
Your pull request has some changes, I should incorporate like the output. |
Mhm. I think we cannot importe bcc into python packages since it depends on the kernel version. |
Do we really need a dedicated python output? Bcc already depends on python anyway. |
@@ -47,13 +58,17 @@ stdenv.mkDerivation rec { | |||
|
|||
find $out/share/bcc/tools -type f -executable -print0 | \ | |||
while IFS= read -r -d ''$'\0' f; do | |||
pythonLibs="$out/lib/python2.7/site-packages:${pythonPackages.netaddr}/lib/${python.libPrefix}/site-packages" | |||
pythonLibs="${if pythonSupport then "$py" else "$out"}/lib/python2.7/site-packages:${pythonPackages.netaddr}/lib/${python.libPrefix}/site-packages" |
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.
use ${python.sitePackages}
''; | ||
'' | ||
+ lib.optionalString pythonSupport '' | ||
moveToOutput lib/python2.7 "$py" |
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.
${python.libPrefix}
?
ah nice that you put up a package. I am not that knowledgeable with bcc, I wanted to use it to trace and collect statistics on some kernel functions rather than adding printk's. Your python.pkgs.buildPythonApplication might be a better approach then. Feel free to close this |
on second thought with the buildPythonApplication, will I be able to import bcc and write my own apps ? |
No. |
@FRidh are you sure? the PYTHONPATH was set correctly in a nix-shell: $ nix-shell -p linuxPackages.bcc
bash: /run/user/1000/env-vars: cannot overwrite existing file
[nix-shell:~/git/nixpkgs]$ echo $PYTHONPATH
/nix/store/d90chi5qw76bbncy4b1b0qb2m065c7yh-bcc-0.5.0/lib/python3.6/site-packages:...
[nix-shell:~/git/nixpkgs]$ python
Python 3.6.5 (default, Mar 28 2018, 10:24:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcc |
Also the following snippet works fine: with import <nixpkgs> {};
python3.pkgs.buildPythonApplication {
name = "bcc-app";
format = "other";
unpackPhase = ":";
installPhase = ''
mkdir -p $out/bin/
cat > $out/bin/script <<EOF
#!/usr/bin/env python
import bcc
print("hello")
EOF
chmod +x $out/bin/script
'';
propagatedBuildInputs = [ linuxPackages.bcc ];
} $ nix-build
$ result/bin/script
hello So I would say, yes, you can use my version to build your own applications on top of bcc. |
Technically it works with the current implementation but it is not supposed to (#11423). How would one use this with |
Note that with |
I suppose |
How is that any different for |
I thought your concern was about importing from top-level. |
It is, I thought you were referring to having to use But, the actual issue is, as you pointed out, that it is made for a certain kernel version. Is it a problem that users of the Python library would have to use |
I would have liked to use
|
Add bcc python bindings (https://github.com/iovisor/bcc), aka tools to
play with BPF and kernel.
Motivation for this change
I want to load BPF programs via python.
I haven't properly tested everything yet but the bindings seemed to work (got an error when loading my bpf filter but unrelated I think)
@RAGGE
@Mic92
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)