Closed ghost closed 3 months ago
Thanks Taheera :) It does not seem to be linked to a specific version of Python, actually.
This is how I checked it (just for reference):
$ for v in {9..13}; do nix-shell --pure -p copier -p python3$v --run 'copier copy --trust gh:ninanor/python-template /tmp/test --defaults' >&/dev/null && echo "Python 3.$v good" || echo "Python 3.$v bad"; rm -rf /tmp/test; done
Python 3.9 good
Python 3.10 good
Python 3.11 good
Python 3.12 good
Python 3.13 good
I found some comments on the web that this issue could be related to setuptools or pip. It turns out that this comment about the pip version being too old is correct.
I made a nix shell template named shell.nix.envsubst
:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs.buildPackages;
let
custom = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/$rev) {};
in
[
copier
cacert
custom.python39Packages.pip
];
}
Then I made a small script to check different versions of pip based on older snapshots of NIX, specifically:
Here is the script:
#!/bin/bash
for r in bf7d05e64d1172ad9356b87bc8c2a643f600e1f0 c2828e8479f84baaf176d0986164231e408d6e1a
do
rev=$r envsubst < shell.nix.envsubst > shell.nix
nix-shell --pure --run 'copier copy --trust gh:ninanor/python-template /tmp/test --defaults' &>/dev/null &&
echo "Revision $r good" ||
echo "Revision $r bad"
rm -rf /tmp/test
done
Here is the result:
Revision bf7d05e64d1172ad9356b87bc8c2a643f600e1f0 bad
Revision c2828e8479f84baaf176d0986164231e408d6e1a good
So, your version of pip is too old. I think that we should not try to fix at the code level and just target more recent versions of Python and pip.
Solution: upgrade to a newer version of pip :) For example:
pip install pip
Or, as a user:
pip install --user pip --ignore-installed pip
I get an error when using the template using Python 3.12.4