From b5de795ba9ee2b15fee9881cc1de4ddc9131fe35 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 28 May 2024 18:39:11 +0200 Subject: [PATCH 1/8] python312Packages.attrs-strict: init at 1.0.1 --- .../python-modules/attrs-strict/default.nix | 42 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 44 insertions(+) create mode 100644 pkgs/development/python-modules/attrs-strict/default.nix diff --git a/pkgs/development/python-modules/attrs-strict/default.nix b/pkgs/development/python-modules/attrs-strict/default.nix new file mode 100644 index 000000000000..8f3e9a8548df --- /dev/null +++ b/pkgs/development/python-modules/attrs-strict/default.nix @@ -0,0 +1,42 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + attrs, + setuptools, + setuptools-scm, +}: + +buildPythonPackage rec { + pname = "attrs-strict"; + version = "1.0.1"; + pyproject = true; + + src = fetchPypi { + inherit version; + pname = "attrs_strict"; + hash = "sha256-5wSGNiAUbF8qi2Ac1FdNFIkT2yb8Bjb5Qf5CEuQl6v4="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + attrs + ]; + + pythonImportsCheck = [ "attrs_strict" ]; + + # No tests in the pypi archive + doCheck = false; + + meta = { + changelog = "https://github.com/bloomberg/attrs-strict/releases/tag/${version}"; + description = "Python package which contains runtime validation for attrs data classes based on the types existing in the typing module"; + homepage = "https://github.com/bloomberg/attrs-strict"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 54ce24d46f25..7f2202f1cdbf 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1053,6 +1053,8 @@ self: super: with self; { attrs = callPackage ../development/python-modules/attrs { }; + attrs-strict = callPackage ../development/python-modules/attrs-strict { }; + aubio = callPackage ../development/python-modules/aubio { }; audible = callPackage ../development/python-modules/audible { }; From 75ffe9e0a853e027dd85d1199426b79c6726e992 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 25 Mar 2025 19:57:43 +0100 Subject: [PATCH 2/8] python312Packages.mirakuru: unbreak build by disabling one test --- .../development/python-modules/mirakuru/default.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/mirakuru/default.nix b/pkgs/development/python-modules/mirakuru/default.nix index b8739779aa77..573548da6825 100644 --- a/pkgs/development/python-modules/mirakuru/default.nix +++ b/pkgs/development/python-modules/mirakuru/default.nix @@ -51,11 +51,14 @@ buildPythonPackage rec { # > ps: vsz: requires entitlement # > ps: rss: requires entitlement # > ps: time: requires entitlement - disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ - "test_forgotten_stop" - "test_mirakuru_cleanup" - "test_daemons_killing" - ]; + disabledTests = + [ + "test_forgotten_stop" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + "test_mirakuru_cleanup" + "test_daemons_killing" + ]; meta = with lib; { homepage = "https://pypi.org/project/mirakuru"; From b7ec5ffeca7d77ebd642d2d506f9f07c6abdf237 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 May 2024 11:00:18 +0200 Subject: [PATCH 3/8] python312Packages.swh-model: init at 7.1.0 --- .../python-modules/swh-model/default.nix | 84 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 86 insertions(+) create mode 100644 pkgs/development/python-modules/swh-model/default.nix diff --git a/pkgs/development/python-modules/swh-model/default.nix b/pkgs/development/python-modules/swh-model/default.nix new file mode 100644 index 000000000000..31e0cba03ac2 --- /dev/null +++ b/pkgs/development/python-modules/swh-model/default.nix @@ -0,0 +1,84 @@ +{ + lib, + stdenv, + buildPythonPackage, + fetchFromGitLab, + setuptools, + setuptools-scm, + attrs, + attrs-strict, + dateutils, + deprecated, + hypothesis, + iso8601, + typing-extensions, + click, + dulwich, + aiohttp, + pytestCheckHook, + pytz, + types-click, + types-python-dateutil, + types-pytz, + types-deprecated, + +}: + +buildPythonPackage rec { + pname = "swh-model"; + version = "7.1.0"; + pyproject = true; + + src = fetchFromGitLab { + domain = "gitlab.softwareheritage.org"; + group = "swh"; + owner = "devel"; + repo = "swh-model"; + tag = "v${version}"; + hash = "sha256-I0DaSipE5TVFqAdGkNo4e66l1x4A26EYk0F4tKMy33k="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + attrs + attrs-strict + click + dulwich + dateutils + deprecated + hypothesis + iso8601 + typing-extensions + ]; + + pythonImportsCheck = [ "swh.model" ]; + + nativeCheckInputs = [ + aiohttp + click + pytestCheckHook + pytz + types-click + types-python-dateutil + types-pytz + types-deprecated + ]; + + pytestFlagsArray = lib.optionals (stdenv.hostPlatform.isDarwin) [ + # OSError: [Errno 92] Illegal byte sequence + "--deselect swh/model/tests/test_cli.py::TestIdentify::test_exclude" + "--deselect swh/model/tests/test_from_disk.py::DirectoryToObjects::test_exclude" + "--deselect swh/model/tests/test_from_disk.py::DirectoryToObjects::test_exclude_trailing" + ]; + + meta = { + description = "Implementation of the Data model of the Software Heritage project, used to archive source code artifacts"; + homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-model"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 7f2202f1cdbf..65a31e954ece 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17349,6 +17349,8 @@ self: super: with self; { swagger-ui-bundle = callPackage ../development/python-modules/swagger-ui-bundle { }; + swh-model = callPackage ../development/python-modules/swh-model { }; + swift = callPackage ../development/python-modules/swift { }; swifter = callPackage ../development/python-modules/swifter { }; From 02d6bc8d89f72ff32b9105e767a48775425d6c71 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 May 2024 11:01:33 +0200 Subject: [PATCH 4/8] python312Packages.swh-core: init at 4.0.0 --- .../python-modules/swh-core/default.nix | 127 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 129 insertions(+) create mode 100644 pkgs/development/python-modules/swh-core/default.nix diff --git a/pkgs/development/python-modules/swh-core/default.nix b/pkgs/development/python-modules/swh-core/default.nix new file mode 100644 index 000000000000..b3ff2d4ac851 --- /dev/null +++ b/pkgs/development/python-modules/swh-core/default.nix @@ -0,0 +1,127 @@ +{ + lib, + stdenv, + buildPythonPackage, + fetchFromGitLab, + backports-entry-points-selectable, + click, + deprecated, + python-magic, + pyyaml, + requests, + sentry-sdk_2, + tenacity, + setuptools, + setuptools-scm, + flask, + hypothesis, + iso8601, + lzip, + msgpack, + psycopg, + pylzma, + pytestCheckHook, + pytest-aiohttp, + pytest-mock, + pytest-postgresql, + pytz, + requests-mock, + types-deprecated, + types-psycopg2, + types-pytz, + types-pyyaml, + types-requests, + unzip, + pkgs, # Only for pkgs.zstd +}: + +buildPythonPackage rec { + pname = "swh-core"; + version = "4.0.0"; + pyproject = true; + + src = fetchFromGitLab { + domain = "gitlab.softwareheritage.org"; + group = "swh"; + owner = "devel"; + repo = "swh-core"; + tag = "v${version}"; + hash = "sha256-kO4B25+oQrQ9sxmKJ5NMKTCCGztRaArFtD7QA8Bytts="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + backports-entry-points-selectable + click + deprecated + python-magic + pyyaml + requests + sentry-sdk_2 + tenacity + ]; + + pythonImportsCheck = [ "swh.core" ]; + + __darwinAllowLocalNetworking = true; + + nativeCheckInputs = [ + flask + hypothesis + iso8601 + lzip + msgpack + psycopg + pylzma + pytestCheckHook + pytest-aiohttp + pytest-mock + pytest-postgresql + pytz + requests-mock + types-deprecated + types-psycopg2 + types-pytz + types-pyyaml + types-requests + unzip + pkgs.zstd + ]; + + disabledTests = + [ + # ValueError: Unable to configure handler 'systemd' + "test_logging_configure_from_yaml" + ] + ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + # FileExistsError: [Errno 17] File exists: + "test_uncompress_upper_archive_extension" + # AssertionError: |500 - 632.1152460000121| not within 100 + "test_timed_coroutine" + "test_timed_start_stop_calls" + "test_timed" + "test_timed_no_metric" + ]; + + disabledTestPaths = [ + # ModuleNotFoundError: No module named 'aiohttp_utils' + "swh/core/api/tests/test_async.py" + "swh/core/api/tests/test_rpc_server_asynchronous.py" + # ModuleNotFoundError: No module named 'systemd' + "swh/core/tests/test_logger.py" + # ModuleNotFoundError: No module named 'psycopg_pool' + "swh/core/db/tests" + ]; + + meta = { + description = "Low-level utilities and helpers used by almost all other modules in the stack"; + homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-core"; + license = lib.licenses.gpl3Only; + mainProgram = "swh"; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 65a31e954ece..a989a6b2dcd1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17349,6 +17349,8 @@ self: super: with self; { swagger-ui-bundle = callPackage ../development/python-modules/swagger-ui-bundle { }; + swh-core = callPackage ../development/python-modules/swh-core { }; + swh-model = callPackage ../development/python-modules/swh-model { }; swift = callPackage ../development/python-modules/swift { }; From 012061fe940978661af6da7e090d5f4073258c4b Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 May 2024 11:03:36 +0200 Subject: [PATCH 5/8] python312Packages.swh-auth: init at 0.10.0 --- .../python-modules/swh-auth/default.nix | 66 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 68 insertions(+) create mode 100644 pkgs/development/python-modules/swh-auth/default.nix diff --git a/pkgs/development/python-modules/swh-auth/default.nix b/pkgs/development/python-modules/swh-auth/default.nix new file mode 100644 index 000000000000..5a5e7e4cc85b --- /dev/null +++ b/pkgs/development/python-modules/swh-auth/default.nix @@ -0,0 +1,66 @@ +{ + lib, + buildPythonPackage, + fetchFromGitLab, + setuptools, + setuptools-scm, + click, + python-keycloak, + python-jose, + pyyaml, + swh-core, + aiocache, + httpx, + pytestCheckHook, + pytest-django, + pytest-mock, + djangorestframework, + starlette, +}: + +buildPythonPackage rec { + pname = "swh-auth"; + version = "0.10.0"; + pyproject = true; + + src = fetchFromGitLab { + domain = "gitlab.softwareheritage.org"; + group = "swh"; + owner = "devel"; + repo = "swh-auth"; + tag = "v${version}"; + hash = "sha256-8ctd5D7zT66oVNZlvRIs8pN7Fe2BhTgC+S9p1HBDO9E="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + click + python-keycloak + python-jose + pyyaml + swh-core + ]; + + pythonImportsCheck = [ "swh.auth" ]; + + nativeCheckInputs = [ + aiocache + djangorestframework + httpx + pytestCheckHook + pytest-django + pytest-mock + starlette + ]; + + meta = { + description = "Set of utility libraries related to user authentication in applications and services based on the use of Keycloak and OpenID Connect"; + homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-auth"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a989a6b2dcd1..82240f4248d3 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17349,6 +17349,8 @@ self: super: with self; { swagger-ui-bundle = callPackage ../development/python-modules/swagger-ui-bundle { }; + swh-auth = callPackage ../development/python-modules/swh-auth { }; + swh-core = callPackage ../development/python-modules/swh-core { }; swh-model = callPackage ../development/python-modules/swh-model { }; From 7c04f0b5a70b1ae35c50b1fa45df5630278269b6 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 29 May 2024 11:02:55 +0200 Subject: [PATCH 6/8] python312Packages.swh-web-client: init at 0.9.0 --- .../python-modules/swh-web-client/default.nix | 66 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 68 insertions(+) create mode 100644 pkgs/development/python-modules/swh-web-client/default.nix diff --git a/pkgs/development/python-modules/swh-web-client/default.nix b/pkgs/development/python-modules/swh-web-client/default.nix new file mode 100644 index 000000000000..79b68cc1b926 --- /dev/null +++ b/pkgs/development/python-modules/swh-web-client/default.nix @@ -0,0 +1,66 @@ +{ + lib, + buildPythonPackage, + fetchFromGitLab, + setuptools, + setuptools-scm, + click, + dateutils, + requests, + swh-auth, + swh-core, + swh-model, + pytestCheckHook, + pytest-mock, + requests-mock, + types-python-dateutil, + types-pyyaml, + types-requests, +}: + +buildPythonPackage rec { + pname = "swh-web-client"; + version = "0.9.0"; + pyproject = true; + + src = fetchFromGitLab { + domain = "gitlab.softwareheritage.org"; + group = "swh"; + owner = "devel"; + repo = "swh-web-client"; + tag = "v${version}"; + hash = "sha256-/h3TaEwo2+B89KFpIKi9LH0tlGplsv3y18pC0TKM0jA="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + click + dateutils + requests + swh-auth + swh-core + swh-model + ]; + + pythonImportsCheck = [ "swh.web.client" ]; + + nativeCheckInputs = [ + pytestCheckHook + pytest-mock + requests-mock + types-python-dateutil + types-pyyaml + types-requests + ]; + + meta = { + description = "Client for Software Heritage Web applications, via their APIs"; + homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-web-client"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 82240f4248d3..0e8cfc9f9bce 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17355,6 +17355,8 @@ self: super: with self; { swh-model = callPackage ../development/python-modules/swh-model { }; + swh-web-client = callPackage ../development/python-modules/swh-web-client { }; + swift = callPackage ../development/python-modules/swift { }; swifter = callPackage ../development/python-modules/swifter { }; From c10fe0a9c2c1207f6e9c1f8ca8ccbad603d4bd50 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Fri, 8 Nov 2024 13:36:51 +0100 Subject: [PATCH 7/8] python312Packages.swh-scanner: init at 0.8.3 --- .../python-modules/swh-scanner/default.nix | 84 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 86 insertions(+) create mode 100644 pkgs/development/python-modules/swh-scanner/default.nix diff --git a/pkgs/development/python-modules/swh-scanner/default.nix b/pkgs/development/python-modules/swh-scanner/default.nix new file mode 100644 index 000000000000..84aec2c17944 --- /dev/null +++ b/pkgs/development/python-modules/swh-scanner/default.nix @@ -0,0 +1,84 @@ +{ + lib, + buildPythonPackage, + fetchFromGitLab, + setuptools, + setuptools-scm, + requests, + ndjson, + flask, + importlib-metadata, + swh-core, + swh-model, + swh-auth, + swh-web-client, + beautifulsoup4, + pytestCheckHook, + pytest-flask, + pytest-mock, + types-beautifulsoup4, + types-pyyaml, + types-requests, +}: + +buildPythonPackage rec { + pname = "swh-scanner"; + version = "0.8.3"; + pyproject = true; + + src = fetchFromGitLab { + domain = "gitlab.softwareheritage.org"; + group = "swh"; + owner = "devel"; + repo = "swh-scanner"; + tag = "v${version}"; + hash = "sha256-baUUuYFapBD7iuDaDP8CSR9f4glVZcS5qBpZddVf7z8="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + requests + ndjson + flask + importlib-metadata + swh-core + swh-model + swh-auth + swh-web-client + ]; + + pythonImportsCheck = [ "swh.scanner" ]; + + nativeCheckInputs = [ + beautifulsoup4 + pytestCheckHook + pytest-flask + pytest-mock + swh-core + swh-model + types-beautifulsoup4 + types-pyyaml + types-requests + ]; + + disabledTests = [ + # AttributeError: 'called_once' is not a valid assertion. Use a spec for the mock if 'called_once' is meant to be an attribute. + "test_scan_api_url_option_success" + ]; + + disabledTestPaths = [ + # pytestRemoveBytecodePhase fails with: "error (ignored): error: opening directory "/tmp/nix-build-python3.12-swh-scanner-0.8.3.drv-5/build/pytest-of-nixbld/pytest-0/test_randomdir_policy_info_cal0/big-directory/dir/dir/dir/ ......" + "swh/scanner/tests/test_policy.py" + ]; + + meta = { + description = "Implementation of the Data model of the Software Heritage project, used to archive source code artifacts"; + homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-model"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ drupol ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0e8cfc9f9bce..6fbb3a83d254 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17355,6 +17355,8 @@ self: super: with self; { swh-model = callPackage ../development/python-modules/swh-model { }; + swh-scanner = callPackage ../development/python-modules/swh-scanner { }; + swh-web-client = callPackage ../development/python-modules/swh-web-client { }; swift = callPackage ../development/python-modules/swift { }; From f415886205781102a38502a616aa91541d0e8f75 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 26 Mar 2025 22:18:48 +0100 Subject: [PATCH 8/8] swh: init at 4.0.0 Wrap `swh` application with `writeShellApplication` to avoid exposing internal Python modules. Using `writeShellApplication` ensures that the underlying Python packages and modules remain hidden. `toPythonApplication` could not be used due to infinite recursion issues caused by circular dependencies between Python modules. --- pkgs/by-name/sw/swh/package.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pkgs/by-name/sw/swh/package.nix diff --git a/pkgs/by-name/sw/swh/package.nix b/pkgs/by-name/sw/swh/package.nix new file mode 100644 index 000000000000..ef90e1d9cf34 --- /dev/null +++ b/pkgs/by-name/sw/swh/package.nix @@ -0,0 +1,24 @@ +{ + python3Packages, + writeShellApplication, + withSwhPythonPackages ? [ + python3Packages.swh-auth + python3Packages.swh-model + python3Packages.swh-scanner + python3Packages.swh-web-client + ], +}: + +let + python3' = python3Packages.python.withPackages (ps: with ps; [ swh-core ] ++ withSwhPythonPackages); +in +writeShellApplication { + name = "swh"; + text = '' + ${python3'}/bin/swh "$@" + ''; + meta = { + inherit (python3Packages.swh-core.meta) license mainProgram platforms; + description = "Software Heritage command-line client"; + }; +}