diff --git a/.gitignore b/.gitignore index 18e905c..669f8f0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ Thumbs.db # Nix Cache to speed up tests .nix/ +.nix-dev-installed # Ignore logs *.log diff --git a/flake.nix b/flake.nix index 44ed837..5ade11f 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,7 @@ ########################################################################## packages = forAllSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = nixpkgs.legacyPackages.${system}; pyPkgs = pkgs.python311Packages; in rec { @@ -45,7 +45,7 @@ pyPkgs.wheel ]; - # Runtime dependencies (matches [project.dependencies]) + # Runtime dependencies (matches [project.dependencies] in pyproject.toml) propagatedBuildInputs = [ pyPkgs.pyyaml pyPkgs.pip @@ -55,6 +55,7 @@ pythonImportsCheck = [ "pkgmgr" ]; }; + default = pkgmgr; } ); @@ -65,29 +66,35 @@ devShells = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; - pkgmgrPkg = self.packages.${system}.pkgmgr; ansiblePkg = if pkgs ? ansible-core then pkgs.ansible-core else pkgs.ansible; - # Python 3 + pip für alles, was "python3 -m pip" macht - pythonWithPip = pkgs.python3.withPackages (ps: [ + # Python 3.11 + pip + PyYAML direkt aus Nix + pythonWithDeps = pkgs.python311.withPackages (ps: [ ps.pip + ps.pyyaml ]); in { default = pkgs.mkShell { buildInputs = [ - pythonWithPip - pkgmgrPkg + pythonWithDeps pkgs.git ansiblePkg ]; shellHook = '' + # Ensure src/ layout is importable: + # pkgmgr lives in ./src/pkgmgr + export PYTHONPATH="$PWD/src:${PYTHONPATH:-}" + # Also add repo root in case tools/tests rely on it + export PYTHONPATH="$PWD:$PYTHONPATH" + echo "Entered pkgmgr development shell for ${system}" - echo "pkgmgr CLI is available via the flake build" + echo "pkgmgr CLI (from source) is available via:" + echo " python -m pkgmgr.cli --help" ''; }; } diff --git a/pyproject.toml b/pyproject.toml index f2013ce..31906a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,4 +49,3 @@ include = ["pkgmgr*", "config*"] [tool.setuptools.package-data] "config" = ["defaults.yaml"] - diff --git a/scripts/test/test-integration.sh b/scripts/test/test-integration.sh index c9a445d..63f82a2 100755 --- a/scripts/test/test-integration.sh +++ b/scripts/test/test-integration.sh @@ -20,7 +20,7 @@ docker run --rm \ set -e; git config --global --add safe.directory /src || true; nix develop .#default --no-write-lock-file -c \ - python -m unittest discover \ + python3 -m unittest discover \ -s tests/integration \ -t /src \ -p "$TEST_PATTERN"; diff --git a/scripts/test/test-unit.sh b/scripts/test/test-unit.sh index d470852..45508e7 100755 --- a/scripts/test/test-unit.sh +++ b/scripts/test/test-unit.sh @@ -20,7 +20,7 @@ docker run --rm \ set -e; git config --global --add safe.directory /src || true; nix develop .#default --no-write-lock-file -c \ - python -m unittest discover \ + python3 -m unittest discover \ -s tests/unit \ -t /src \ -p "$TEST_PATTERN"; diff --git a/src/pkgmgr/__init__.py b/src/pkgmgr/__init__.py index e69de29..42bb4c7 100644 --- a/src/pkgmgr/__init__.py +++ b/src/pkgmgr/__init__.py @@ -0,0 +1,14 @@ +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"]