os/profiles/develop/python/default.nix

43 lines
993 B
Nix
Raw Normal View History

2020-01-31 16:49:47 +00:00
{ pkgs, ... }:
let inherit (pkgs) python3Packages;
in {
environment.systemPackages = let
packages = pythonPackages:
with pythonPackages; [
numpy
pandas
ptpython
requests
scipy
];
python = pkgs.python3.withPackages packages;
in [ python ];
environment.sessionVariables = {
PYTHONSTARTUP = let
startup = pkgs.writers.writePython3 "ptpython.py" {
libraries = with python3Packages; [ ptpython ];
2020-01-31 16:49:47 +00:00
} ''
from __future__ import unicode_literals
from pygments.token import Token
from ptpython.layout import CompletionVisualisation
2020-01-31 16:49:47 +00:00
import sys
${builtins.readFile ./ptconfig.py}
2020-01-31 16:49:47 +00:00
try:
from ptpython.repl import embed
except ImportError:
print("ptpython is not available: falling back to standard prompt")
else:
sys.exit(embed(globals(), locals(), configure=configure))
2020-01-31 16:49:47 +00:00
'';
in "${startup}";
};
}