devos/profiles/develop/python/default.nix

48 lines
1.1 KiB
Nix
Raw Normal View History

2020-01-31 17:49:47 +01:00
{ pkgs, ... }:
let inherit (pkgs) python3Packages;
2020-07-31 06:17:28 +02:00
in
{
environment.systemPackages =
let
packages = pythonPackages:
with pythonPackages; [
numpy
pandas
ptpython
requests
scipy
];
python = pkgs.python3.withPackages packages;
in
[ python ];
2020-01-31 17:49:47 +01:00
environment.sessionVariables = {
2020-07-31 06:17:28 +02:00
PYTHONSTARTUP =
let
startup = pkgs.writers.writePython3 "ptpython.py"
{
libraries = with python3Packages; [ ptpython ];
} ''
from __future__ import unicode_literals
from pygments.token import Token
from ptpython.layout import CompletionVisualisation
import sys
${builtins.readFile ./ptconfig.py}
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))
'';
in
"${startup}";
2020-01-31 17:49:47 +01:00
};
}