From c6b45b1dadc9f041c682ecef84b01e2ab752126f Mon Sep 17 00:00:00 2001 From: sarahec Date: Sat, 24 Aug 2024 14:58:51 -0700 Subject: [PATCH] python3Packages.scalene: 1.5.43.2 -> 1.5.44.1 --- .../scalene/01-manifest-no-git.patch | 23 +++++++ .../02-pyproject-unpin-setuptools.patch | 23 +++++++ .../python-modules/scalene/default.nix | 60 +++++++++++++++---- 3 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 pkgs/development/python-modules/scalene/01-manifest-no-git.patch create mode 100644 pkgs/development/python-modules/scalene/02-pyproject-unpin-setuptools.patch diff --git a/pkgs/development/python-modules/scalene/01-manifest-no-git.patch b/pkgs/development/python-modules/scalene/01-manifest-no-git.patch new file mode 100644 index 0000000000000..85f4bf7e86b49 --- /dev/null +++ b/pkgs/development/python-modules/scalene/01-manifest-no-git.patch @@ -0,0 +1,23 @@ +From 4e25ccee2f1eeed1dfdd9356b4fde511a48d9f01 Mon Sep 17 00:00:00 2001 +From: Sarah Clark +Date: Sat, 24 Aug 2024 11:32:38 -0700 +Subject: [PATCH] Update MANIFEST.in to remove .git references + +--- + MANIFEST.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/MANIFEST.in b/MANIFEST.in +index 5ebcb7781..7340b1982 100644 +--- a/MANIFEST.in ++++ b/MANIFEST.in +@@ -1,5 +1,5 @@ + graft vendor/Heap-Layers +-prune vendor/Heap-Layers/.git ++# prune vendor/Heap-Layers/.git + graft vendor/printf +-prune vendor/printf/.git ++# prune vendor/printf/.git + exclude scalene/old/* + +-- diff --git a/pkgs/development/python-modules/scalene/02-pyproject-unpin-setuptools.patch b/pkgs/development/python-modules/scalene/02-pyproject-unpin-setuptools.patch new file mode 100644 index 0000000000000..80ab0080e631f --- /dev/null +++ b/pkgs/development/python-modules/scalene/02-pyproject-unpin-setuptools.patch @@ -0,0 +1,23 @@ +From 777be9c46c4caed5f3fcde65b70ada4d773f4298 Mon Sep 17 00:00:00 2001 +From: Sarah Clark +Date: Sat, 24 Aug 2024 11:26:30 -0700 +Subject: [PATCH] Unpin setuptools + +--- + pyproject.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pyproject.toml b/pyproject.toml +index d17d12dc8..6bf1c7a38 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -54,7 +54,7 @@ scalene = "scalene.__main__:main" + [build-system] + build-backend = "setuptools.build_meta" + requires = [ +- "setuptools>=65.5.1,<71.0", # Pin to setuptools<71.0 to avoid this bug: https://github.com/pypa/setuptools/issues/4496 ++ "setuptools>=65.5.1", + "setuptools_scm>=8", + "wheel", + "cython", +-- diff --git a/pkgs/development/python-modules/scalene/default.nix b/pkgs/development/python-modules/scalene/default.nix index 6f5adae67d84f..820de7be473b3 100644 --- a/pkgs/development/python-modules/scalene/default.nix +++ b/pkgs/development/python-modules/scalene/default.nix @@ -2,33 +2,67 @@ lib, stdenv, buildPythonPackage, - hypothesis, - fetchPypi, - setuptools, - setuptools-scm, + fetchFromGitHub, cloudpickle, cython, + hypothesis, jinja2, numpy, + nvidia-ml-py, psutil, pynvml, - nvidia-ml-py, pytestCheckHook, pythonOlder, rich, + setuptools-scm, + setuptools, }: +let + heap-layers-src = fetchFromGitHub { + owner = "emeryberger"; + repo = "heap-layers"; + name = "Heap-Layers"; + rev = "a2048eae91b531dc5d72be7a194e0b333c06bd4c"; + sha256 = "sha256-vl3z30CBX7hav/DM/UE0EQ9lLxZF48tMJrYMXuSulyA="; + }; + + printf-src = fetchFromGitHub { + owner = "mpaland"; + repo = "printf"; + name = "printf"; + rev = "v4.0.0"; + sha256 = "sha256-tgLJNJw/dJGQMwCmfkWNBvHB76xZVyyfVVplq7aSJnI="; + }; +in + buildPythonPackage rec { pname = "scalene"; - version = "1.5.43.2"; + version = "1.5.44.1"; pyproject = true; disabled = pythonOlder "3.9"; - src = fetchPypi { - inherit pname version; - hash = "sha256-LtD7v3pLz4UCnh6xlhkPdcEjyu3mt+YQPYZ0nNCLuDw="; + src = fetchFromGitHub { + owner = "plasma-umass"; + repo = "scalene"; + rev = "v${version}"; + hash = "sha256-XMz+gwiNaKiKplD4kOE1yhcg+dkzjEdDYjW0JsDEMQE="; }; + patches = [ + ./01-manifest-no-git.patch + ./02-pyproject-unpin-setuptools.patch + ]; + + prePatch = '' + cp -r ${heap-layers-src} vendor/Heap-Layers + mkdir vendor/printf + cp ${printf-src}/printf.c vendor/printf/printf.cpp + cp -r ${printf-src}/* vendor/printf + sed -i"" 's/^#define printf printf_/\/\/&/' vendor/printf/printf.h + sed -i"" 's/^#define vsnprintf vsnprintf_/\/\/&/' vendor/printf/printf.h + ''; + nativeBuildInputs = [ cython setuptools @@ -38,9 +72,10 @@ buildPythonPackage rec { propagatedBuildInputs = [ cloudpickle jinja2 + numpy psutil - rich pynvml + rich ] ++ lib.optionals stdenv.hostPlatform.isLinux [ nvidia-ml-py ]; pythonRemoveDeps = [ @@ -56,6 +91,11 @@ buildPythonPackage rec { numpy ]; + disabledTests = [ + # Flaky -- socket collision + "test_show_browser" + ]; + # remove scalene directory to prevent pytest import confusion preCheck = '' rm -rf scalene