1{ stdenv 2, buildPythonPackage 3, fetchFromGitHub 4, python 5, bootstrapped-pip 6, lib 7, pipInstallHook 8, setuptoolsBuildHook 9}: 10 11let 12 pname = "setuptools"; 13 version = "65.3.0"; 14 15 # Create an sdist of setuptools 16 sdist = stdenv.mkDerivation rec { 17 name = "${pname}-${version}-sdist.tar.gz"; 18 19 src = fetchFromGitHub { 20 owner = "pypa"; 21 repo = pname; 22 rev = "refs/tags/v${version}"; 23 hash = "sha256-LPguGVWvwEMZpJFuXWLVFzIlzw+/QSMjVi2oYh0cI0s="; 24 name = "${pname}-${version}-source"; 25 }; 26 27 patches = [ 28 ./tag-date.patch 29 ./setuptools-distutils-C++.patch 30 ]; 31 32 buildPhase = '' 33 ${python.pythonForBuild.interpreter} setup.py egg_info 34 ${python.pythonForBuild.interpreter} setup.py sdist --formats=gztar 35 36 # Here we untar the sdist and retar it in order to control the timestamps 37 # of all the files included 38 tar -xzf dist/${pname}-${version}.post0.tar.gz -C dist/ 39 tar -czf dist/${name} -C dist/ --mtime="@$SOURCE_DATE_EPOCH" --sort=name ${pname}-${version}.post0 40 ''; 41 42 installPhase = '' 43 echo "Moving sdist..." 44 mv dist/${name} $out 45 ''; 46 }; 47in buildPythonPackage rec { 48 inherit pname version; 49 # Because of bootstrapping we don't use the setuptoolsBuildHook that comes with format="setuptools" directly. 50 # Instead, we override it to remove setuptools to avoid a circular dependency. 51 # The same is done for pip and the pipInstallHook. 52 format = "other"; 53 54 src = sdist; 55 56 nativeBuildInputs = [ 57 bootstrapped-pip 58 (pipInstallHook.override{pip=null;}) 59 (setuptoolsBuildHook.override{setuptools=null; wheel=null;}) 60 ]; 61 62 preBuild = lib.optionalString (!stdenv.hostPlatform.isWindows) '' 63 export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0 64 ''; 65 66 pipInstallFlags = [ "--ignore-installed" ]; 67 68 # Adds setuptools to nativeBuildInputs causing infinite recursion. 69 catchConflicts = false; 70 71 # Requires pytest, causing infinite recursion. 72 doCheck = false; 73 74 meta = with lib; { 75 description = "Utilities to facilitate the installation of Python packages"; 76 homepage = "https://pypi.python.org/pypi/setuptools"; 77 license = with licenses; [ psfl zpl20 ]; 78 platforms = python.meta.platforms; 79 priority = 10; 80 maintainers = teams.python.members; 81 }; 82}