nixpkgs/pkgs/development/python-modules/setuptools/default.nix
Frederik Rietdijk 56727dc1ff Python: setuptools/wheel/pip now bootstrap from source
Since wheel support was introduced in 2015 we always relied on pre-built
wheels for bootstrapping. Now, we can bootstrap directly from the
sources of these packages in git.

The `bootstrapped-pip` packages is used to build `pip`, `setuptools` and `wheel`,
after which those packages are used to build everything else.

Note that when building `bootstrapped-pip` some errors are shown.
These are not important, the build actually does succeed and work as intended.
2019-10-20 19:48:00 +02:00

75 lines
1.9 KiB
Nix

{ stdenv
, buildPythonPackage
, fetchFromGitHub
, python
, wrapPython
, unzip
, callPackage
, bootstrapped-pip
, lib
, pipInstallHook
, setuptoolsBuildHook
}:
let
pname = "setuptools";
version = "41.4.0";
# Create an sdist of setuptools
sdist = stdenv.mkDerivation rec {
name = "${pname}-${version}-sdist.tar.gz";
src = fetchFromGitHub {
owner = "pypa";
repo = pname;
rev = "v${version}";
sha256 = "0asxfnsi56r81lm48ynqbfkmm3kvw2jwrlf2l9azn5w6xm30jvp5";
name = "${pname}-${version}-source";
};
buildPhase = ''
${python.pythonForBuild.interpreter} bootstrap.py
${python.pythonForBuild.interpreter} setup.py sdist --formats=gztar
'';
installPhase = ''
echo "Moving sdist..."
mv dist/*.tar.gz $out
'';
};
in buildPythonPackage rec {
inherit pname version;
# Because of bootstrapping we don't use the setuptoolsBuildHook that comes with format="setuptools" directly.
# Instead, we override it to remove setuptools to avoid a circular dependency.
# The same is done for pip and the pipInstallHook.
format = "other";
src = sdist;
nativeBuildInputs = [
bootstrapped-pip
(pipInstallHook.override{pip=null;})
(setuptoolsBuildHook.override{setuptools=null; wheel=null;})
];
preBuild = lib.strings.optionalString (!stdenv.hostPlatform.isWindows) ''
export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0
'';
pipInstallFlags = [ "--ignore-installed" ];
# Adds setuptools to nativeBuildInputs causing infinite recursion.
catchConflicts = false;
# Requires pytest, causing infinite recursion.
doCheck = false;
meta = with stdenv.lib; {
description = "Utilities to facilitate the installation of Python packages";
homepage = https://pypi.python.org/pypi/setuptools;
license = with licenses; [ psfl zpl20 ];
platforms = python.meta.platforms;
priority = 10;
};
}