From 0f74907f828fcd720637c65d0d1dcf6e1ba22ac4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 11 Dec 2025 10:30:19 +0100 Subject: [PATCH] flake.nix: switch to generic python3 and remove side-effects from pkgmgr package root - Replace hardcoded python311 references with generic python3 to avoid minor version pinning and ensure consistent interpreter selection across systems. - Use python.pkgs instead of python311Packages in the build pipeline. - Update devShell to use python3.withPackages, including pip and pyyaml. - Add Python version echo in shellHook for improved debugging. - Remove cli re-export from src/pkgmgr/__init__.py to eliminate heavy side-effects during import and prevent premature config loading in tests. --- flake.nix | 12 +++++++++--- src/pkgmgr/__init__.py | 14 -------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index 5ade11f..a94bfc3 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,10 @@ packages = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; - pyPkgs = pkgs.python311Packages; + + # Single source of truth: "python3" from this nixpkgs revision + python = pkgs.python3; + pyPkgs = python.pkgs; in rec { pkgmgr = pyPkgs.buildPythonApplication { @@ -71,8 +74,9 @@ if pkgs ? ansible-core then pkgs.ansible-core else pkgs.ansible; - # Python 3.11 + pip + PyYAML direkt aus Nix - pythonWithDeps = pkgs.python311.withPackages (ps: [ + python = pkgs.python3; + + pythonWithDeps = python.withPackages (ps: [ ps.pip ps.pyyaml ]); @@ -93,6 +97,8 @@ export PYTHONPATH="$PWD:$PYTHONPATH" echo "Entered pkgmgr development shell for ${system}" + echo "Python used in this shell:" + python --version echo "pkgmgr CLI (from source) is available via:" echo " python -m pkgmgr.cli --help" ''; diff --git a/src/pkgmgr/__init__.py b/src/pkgmgr/__init__.py index 42bb4c7..e69de29 100644 --- a/src/pkgmgr/__init__.py +++ b/src/pkgmgr/__init__.py @@ -1,14 +0,0 @@ -from __future__ import annotations - -""" -Top-level package for Kevin's package manager (pkgmgr). - -We re-export the CLI subpackage as the attribute ``cli`` so that -``pkgutil.resolve_name("pkgmgr.cli.commands.release")`` and similar -lookups work reliably under Python 3.13+. -""" - -# Re-export the CLI subpackage as an attribute on the package. -from . import cli as cli # type: ignore[F401] - -__all__ = ["cli"]