-
Notifications
You must be signed in to change notification settings - Fork 0
/
python-shell.nix
52 lines (46 loc) · 1.14 KB
/
python-shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
pkgs ? import <nixpkgs> { },
extraBuildInputs ? [ ],
myPython ? pkgs.python3,
extraLibPackages ? [ ],
pythonWithPkgs ? myPython,
}:
let
buildInputs =
with pkgs;
[
clang
llvmPackages_16.bintools
rustup
]
++ extraBuildInputs;
lib-path = with pkgs; lib.makeLibraryPath buildInputs;
shell = pkgs.mkShell {
buildInputs = [
# my python and packages
pythonWithPkgs
# other packages needed for compiling python libs
pkgs.readline
pkgs.libffi
pkgs.openssl
# unfortunately needed because of messing with LD_LIBRARY_PATH below
pkgs.git
pkgs.openssh
pkgs.rsync
] ++ extraBuildInputs;
shellHook = ''
# Allow the use of wheels.
SOURCE_DATE_EPOCH=$(date +%s)
# Augment the dynamic linker path
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}"
# Setup the virtual environment if it doesn't already exist.
VENV=.venv
if test ! -d $VENV; then
virtualenv $VENV
fi
source ./$VENV/bin/activate
export PYTHONPATH=$PYTHONPATH:`pwd`/$VENV/${myPython.sitePackages}/
'';
};
in
shell