1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 hypothesis,
6 fetchPypi,
7 setuptools,
8 setuptools-scm,
9 cloudpickle,
10 cython,
11 jinja2,
12 numpy,
13 psutil,
14 pynvml,
15 nvidia-ml-py,
16 pytestCheckHook,
17 pythonOlder,
18 rich,
19}:
20
21buildPythonPackage rec {
22 pname = "scalene";
23 version = "1.5.42.2";
24 pyproject = true;
25 disabled = pythonOlder "3.9";
26
27 src = fetchPypi {
28 inherit pname version;
29 hash = "sha256-0ZGk0xFBFSeeg4vjNXu/ppGdEKGhUc2ql4R6oWG23aQ=";
30 };
31
32 nativeBuildInputs = [
33 cython
34 setuptools
35 setuptools-scm
36 ];
37
38 propagatedBuildInputs = [
39 cloudpickle
40 jinja2
41 psutil
42 rich
43 pynvml
44 ] ++ lib.optionals stdenv.hostPlatform.isLinux [ nvidia-ml-py ];
45
46 pythonRemoveDeps = [
47 "nvidia-ml-py3"
48 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ "nvidia-ml-py" ];
49
50 __darwinAllowLocalNetworking = true;
51
52 nativeCheckInputs = [ pytestCheckHook ];
53
54 checkInputs = [
55 hypothesis
56 numpy
57 ];
58
59 # remove scalene directory to prevent pytest import confusion
60 preCheck = ''
61 rm -rf scalene
62 '';
63
64 pythonImportsCheck = [ "scalene" ];
65
66 meta = with lib; {
67 description = "High-resolution, low-overhead CPU, GPU, and memory profiler for Python with AI-powered optimization suggestions";
68 homepage = "https://github.com/plasma-umass/scalene";
69 changelog = "https://github.com/plasma-umass/scalene/releases/tag/v${version}";
70 mainProgram = "scalene";
71 license = licenses.asl20;
72 maintainers = with maintainers; [ sarahec ];
73 };
74}