From e4f2d59409f8df55ec826b733c75e2caf6f2a9e8 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 8 May 2025 12:15:10 +0200 Subject: [PATCH 1/2] python3Packages.hatch-autorun: init at 1.1.0 --- .../python-modules/hatch-autorun/default.nix | 52 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 54 insertions(+) create mode 100644 pkgs/development/python-modules/hatch-autorun/default.nix diff --git a/pkgs/development/python-modules/hatch-autorun/default.nix b/pkgs/development/python-modules/hatch-autorun/default.nix new file mode 100644 index 000000000000..434853b00a2f --- /dev/null +++ b/pkgs/development/python-modules/hatch-autorun/default.nix @@ -0,0 +1,52 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + hatch-vcs, + hatchling, + pytestCheckHook, + build, +}: + +buildPythonPackage rec { + pname = "hatch-autorun"; + version = "1.1.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ofek"; + repo = "hatch-autorun"; + tag = "v${version}"; + hash = "sha256-79k3KolvmjGf8ubCQMhtOH5+OeqQrmz2Q6r0ZG98424="; + }; + + build-system = [ + hatch-vcs + hatchling + ]; + + dependencies = [ + hatchling + ]; + + pythonImportsCheck = [ + "hatch_autorun" + ]; + + nativeCheckInputs = [ + pytestCheckHook + build + ]; + + disabledTestPaths = [ + # requires network via invoking pip + "tests/test_build.py" + ]; + + meta = { + description = "Hatch build hook plugin to inject code that will automatically run"; + homepage = "https://github.com/ofek/hatch-autorun"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ pbsds ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c0eb34fc8f6f..892b5f26f0b4 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6186,6 +6186,8 @@ self: super: with self; { hatasmota = callPackage ../development/python-modules/hatasmota { }; + hatch-autorun = callPackage ../development/python-modules/hatch-autorun { }; + hatch-babel = callPackage ../development/python-modules/hatch-babel { }; hatch-fancy-pypi-readme = callPackage ../development/python-modules/hatch-fancy-pypi-readme { }; From bbe729f9d55af82e9cf3018b47eccb70f1b89c61 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 8 May 2025 12:15:39 +0200 Subject: [PATCH 2/2] python3Packages.auto-lazy-imports: init at 0.4.2 --- .../auto-lazy-imports/default.nix | 88 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 90 insertions(+) create mode 100644 pkgs/development/python-modules/auto-lazy-imports/default.nix diff --git a/pkgs/development/python-modules/auto-lazy-imports/default.nix b/pkgs/development/python-modules/auto-lazy-imports/default.nix new file mode 100644 index 000000000000..4ff6cf8b3fa5 --- /dev/null +++ b/pkgs/development/python-modules/auto-lazy-imports/default.nix @@ -0,0 +1,88 @@ +{ + lib, + python, + buildPythonPackage, + fetchFromGitHub, + hatchling, + hatch-autorun, + pytestCheckHook, + runCommand, +}: + +buildPythonPackage rec { + pname = "auto-lazy-imports"; # matches pypi + version = "0.4.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "hmiladhia"; + repo = "lazyimports"; + tag = "v${version}"; + hash = "sha256-DPk/fupBuYmm7Xy5+qFkqeRoglflECuX8A0C2ncARhI="; + }; + + build-system = [ + hatchling + hatch-autorun + ]; + + pythonImportsCheck = [ + "lazyimports" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + preInstallCheck = '' + if [[ -f "$out/${python.sitePackages}"/hatch_autorun_auto_lazy_imports.pth ]]; then + echo >&2 "Found hatch_autorun_auto_lazy_imports.pth in site-packages" + else + echo >&2 "ERROR: no hatch_autorun_auto_lazy_imports.pth file found in site-packages, please re-check derivation assumptions" + false + fi + ''; + + preCheck = '' + # Makes python load the .pth file in site-packages + export NIX_PYTHONPATH="$out/${python.sitePackages}''${NIX_PYTHONPATH:+:"$NIX_PYTHONPATH"}" + ''; + + # check if NIX_PYTHONPATH is properly set in downstream environments + passthru.tests = { + check-autorun-pyenv = + runCommand "${pname}-check-autorun-pyenv" + { + nativeBuildInputs = [ + (python.withPackages (ps: [ + ps.auto-lazy-imports + ps.pytest + ])) + ]; + } + '' + pytest ${src}/tests && touch $out + ''; + + # TODO: this requires user to set NIX_PYTHONPATH + # check-autorun-env = + # runCommand "${pname}-check-autorun-env" + # { + # nativeBuildInputs = [ + # python + # python.pkgs.auto-lazy-imports + # python.pkgs.pytest + # ]; + # } + # '' + # pytest ${src}/tests && touch $out + # ''; + }; + + meta = { + description = "Enable lazy imports using native python syntax"; + homepage = "https://github.com/hmiladhia/lazyimports"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ pbsds ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 892b5f26f0b4..e8092e9301a1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1114,6 +1114,8 @@ self: super: with self; { authres = callPackage ../development/python-modules/authres { }; + auto-lazy-imports = callPackage ../development/python-modules/auto-lazy-imports { }; + autobahn = callPackage ../development/python-modules/autobahn { }; autocommand = callPackage ../development/python-modules/autocommand { };