-
Notifications
You must be signed in to change notification settings - Fork 330
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
python: add patchelf option #840
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
languages.python = { | ||
enable = true; | ||
poetry.enable = true; | ||
venv.patchelf = true; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
inputs: | ||
nixpkgs: | ||
url: github:NixOS/nixpkgs/nixpkgs-unstable | ||
autopatchelf: | ||
url: github:bobvanderlinden/autopatchelf/7fe81db2d94989e41e52fcab65c9d0a88d46e25c |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
|
||
venv.enable = true; | ||
venv.requirements = ./requirements.txt; | ||
venv.patchelf = true; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,16 @@ | |
let | ||
cfg = config.languages.python; | ||
|
||
autopatchelf-flake = inputs.autopatchelf or (throw '' | ||
To use patchelf, you need to add the following to your devenv.yaml: | ||
|
||
inputs: | ||
autopatchelf: | ||
url: github:bobvanderlinden/autopatchelf/7fe81db2d94989e41e52fcab65c9d0a88d46e25c | ||
''); | ||
|
||
autopatchelf = autopatchelf-flake.packages.${pkgs.system}.default; | ||
|
||
requirements = pkgs.writeText "requirements.txt" ( | ||
if lib.isPath cfg.venv.requirements | ||
then builtins.readFile cfg.venv.requirements | ||
|
@@ -135,6 +145,12 @@ in | |
description = "Whether `pip install` should avoid outputting messages during devenv initialisation."; | ||
}; | ||
|
||
venv.patchelf = lib.mkOption { | ||
type = lib.types.bool; | ||
default = false; | ||
description = "Whether to patch ELF files in the Python virtual environment, so that they refer to libraries/packages defined in devenv."; | ||
}; | ||
|
||
poetry = { | ||
enable = lib.mkEnableOption "poetry"; | ||
install = { | ||
|
@@ -219,6 +235,11 @@ in | |
source ${initVenvScript} | ||
'') ++ (lib.optional cfg.poetry.install.enable '' | ||
source ${initPoetryScript} | ||
'') ++ (lib.optional cfg.venv.patchelf '' | ||
if [ -d "$VIRTUAL_ENV" ] | ||
then | ||
${autopatchelf}/bin/autopatchelf --libs ${config.devenv.profile}/lib --path $VIRTUAL_ENV | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know the devenv code well enough but find this approach interesting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback!
Indeed. Maybe storing the profile inside
I presumed the profile is not GCed, as it has a GC root that in |
||
fi | ||
'') | ||
); | ||
}; | ||
|
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.
I wonder if this should be a no-op on non-elf architectures to not break macOS by accident.