-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python: remove
LD_LIBRARY_PATH
hack from running python environment
Injecting `LD_LIBRARY_PATH` to the Python runtime environment is great to bypass the need of having to patch non-nix binaries loaded into that environment, however it breaks down, when Python executes any other program not compiled for the given Nix system, e.g. a shell script via `subprocess`. To work this around, `devenv` will inject a `pth`[^1] file to the virtual environment it creates, which mangles the `LD_LIBRARY_PATH` variable, undoing any changes to it made by `devenv` but preserving changes from other sources. Fixes #1111 [^1]: https://docs.python.org/3/library/site.html
- Loading branch information
Showing
8 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
python - <<EOF | ||
import os | ||
assert "LD_LIBRARY_PATH" not in os.environ | ||
EOF | ||
|
||
LD_LIBRARY_PATH=set-from-shell python - <<EOF | ||
import os | ||
assert os.environ["LD_LIBRARY_PATH"] == "set-from-shell" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
languages.python = { | ||
enable = true; | ||
poetry.enable = true; | ||
libraries = [ pkgs.file ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[tool.poetry] | ||
name = "python-ld-library-path" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Your Name <[email protected]>"] | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
python - <<EOF | ||
import os | ||
assert "LD_LIBRARY_PATH" not in os.environ | ||
EOF | ||
|
||
|
||
LD_LIBRARY_PATH=set-from-shell python - <<EOF | ||
import os | ||
import sys | ||
print(sys.prefix) | ||
assert os.environ["LD_LIBRARY_PATH"] == "set-from-shell" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
languages.python = { | ||
enable = true; | ||
venv.enable = true; | ||
uv.enable = true; | ||
libraries = [ pkgs.file ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
python - <<EOF | ||
import os | ||
assert "LD_LIBRARY_PATH" not in os.environ | ||
EOF | ||
|
||
LD_LIBRARY_PATH=set-from-shell python - <<EOF | ||
import os | ||
assert os.environ["LD_LIBRARY_PATH"] == "set-from-shell" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
languages.python = { | ||
enable = true; | ||
venv.enable = true; | ||
libraries = [ pkgs.file ]; | ||
}; | ||
} |