From cf583e2d44d886ba03d7b89361e753d5ac33c984 Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 21 Jul 2023 01:57:39 +0200 Subject: [PATCH] templates/python: improve shell.nix --- templates/python-project/default.nix | 2 +- templates/python-project/shell.nix | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/templates/python-project/default.nix b/templates/python-project/default.nix index 52684df2..acbef7dd 100644 --- a/templates/python-project/default.nix +++ b/templates/python-project/default.nix @@ -42,7 +42,7 @@ passthru.devDependencies = devDependencies; }; - checkPython = python3.withPackages (ps: devDependencies); + checkPython = python3.withPackages (ps: devDependencies ++ dependencies); check = runCommand "${name}-check" {} '' cp -r ${src} ./src diff --git a/templates/python-project/shell.nix b/templates/python-project/shell.nix index 92bd0d74..318ab24a 100644 --- a/templates/python-project/shell.nix +++ b/templates/python-project/shell.nix @@ -27,19 +27,17 @@ shellHook = '' tmp_path=$(realpath ./.pythonenv) repo_root=$(realpath .) - if ! cmp -s pyproject.toml $tmp_path/pyproject.toml; then - rm -rf $tmp_path - mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}" + rm -rf $tmp_path + mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}" + + ${pythonWithDeps.interpreter} -m pip install \ + --quiet \ + --disable-pip-version-check \ + --no-index \ + --no-build-isolation \ + --prefix "$tmp_path" \ + --editable $repo_root - ${pythonWithDeps.interpreter} -m pip install \ - --quiet \ - --disable-pip-version-check \ - --no-index \ - --no-build-isolation \ - --prefix "$tmp_path" \ - --editable $repo_root && \ - cp -a pyproject.toml $tmp_path/pyproject.toml - fi export PATH="$tmp_path/bin:${checkScript}/bin:$PATH" export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}" '';