19 bootstrap = fetchurl {
20 url = "https://raw.githubusercontent.com/pypa/setuptools/v52.0.0/bootstrap.py";
21 sha256 = "sha256-HzhlnJvMskBfb3kVnYltdnjS63wt1GWd0RK+VQqrJQ8=";
24 # Create an sdist of setuptools
25 sdist = stdenv.mkDerivation rec {
26 name = "${pname}-${version}-sdist.tar.gz";
28 src = fetchFromGitHub {
32 sha256 = "sha256-ZHJZiwlWLHP4vf2TLwj/DYB9wjbRp0apVmmjsKCLPq0=";
33 name = "${pname}-${version}-source";
41 cp ${bootstrap} bootstrap.py
42 ${python.pythonForBuild.interpreter} bootstrap.py
43 ${python.pythonForBuild.interpreter} setup.py sdist --formats=gztar
45 # Here we untar the sdist and retar it in order to control the timestamps
46 # of all the files included
47 tar -xzf dist/${pname}-${version}.post0.tar.gz -C dist/
48 tar -czf dist/${name} -C dist/ --mtime="@$SOURCE_DATE_EPOCH" --sort=name ${pname}-${version}.post0
52 echo "Moving sdist..."
56 in buildPythonPackage rec {
57 inherit pname version;
58 # Because of bootstrapping we don't use the setuptoolsBuildHook that comes with format="setuptools" directly.
59 # Instead, we override it to remove setuptools to avoid a circular dependency.
60 # The same is done for pip and the pipInstallHook.
67 (pipInstallHook.override{pip=null;})
68 (setuptoolsBuildHook.override{setuptools=null; wheel=null;})
71 preBuild = lib.strings.optionalString (!stdenv.hostPlatform.isWindows) ''
72 export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0
75 pipInstallFlags = [ "--ignore-installed" ];
77 # Adds setuptools to nativeBuildInputs causing infinite recursion.
78 catchConflicts = false;
80 # Requires pytest, causing infinite recursion.
84 description = "Utilities to facilitate the installation of Python packages";
85 homepage = "https://pypi.python.org/pypi/setuptools";
86 license = with licenses; [ psfl zpl20 ];
87 platforms = python.meta.platforms;