Merge branch 'nativeCheckInputs' into staging-nativeCheckInputs

This commit is contained in:
Guillaume Girol
2023-01-21 12:00:00 +00:00
4905 changed files with 28229 additions and 52402 deletions
@@ -171,11 +171,22 @@ let
else if isx86_32 then "i386"
else parsed.cpu.name;
pythonAbiName =
# python's build doesn't differentiate between musl and glibc in its
# abi detection, our wrapper should match.
if stdenv.hostPlatform.isMusl then
replaceStrings [ "musl" ] [ "gnu" ] parsed.abi.name
else parsed.abi.name;
# python's build doesn't support every gnu<extension>, and doesn't
# differentiate between musl and glibc, so we list those supported in
# here:
# https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L724
# Note: this is an approximation, as it doesn't take into account the CPU
# family, or the nixpkgs abi naming conventions.
if elem parsed.abi.name [
"gnux32"
"gnueabihf"
"gnueabi"
"gnuabin32"
"gnuabi64"
"gnuspe"
]
then parsed.abi.name
else "gnu";
multiarch =
if isDarwin then "darwin"
else "${multiarchCpu}-${parsed.kernel.name}-${pythonAbiName}";
@@ -1,28 +0,0 @@
# `fetchPypi` function for fetching artifacts from PyPI.
{ fetchurl
, makeOverridable
}:
let
computeUrl = {format ? "setuptools", ... } @attrs: let
computeWheelUrl = {pname, version, dist ? "py2.py3", python ? "py2.py3", abi ? "none", platform ? "any"}:
# Fetch a wheel. By default we fetch an universal wheel.
# See https://www.python.org/dev/peps/pep-0427/#file-name-convention for details regarding the optional arguments.
"https://files.pythonhosted.org/packages/${dist}/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}-${python}-${abi}-${platform}.whl";
computeSourceUrl = {pname, version, extension ? "tar.gz"}:
# Fetch a source tarball.
"mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${pname}-${version}.${extension}";
compute = (if format == "wheel" then computeWheelUrl
else if format == "setuptools" then computeSourceUrl
else throw "Unsupported format ${format}");
in compute (builtins.removeAttrs attrs ["format"]);
in makeOverridable( {format ? "setuptools", sha256 ? "", hash ? "", ... } @attrs:
let
url = computeUrl (builtins.removeAttrs attrs ["sha256" "hash"]) ;
in fetchurl {
inherit url sha256 hash;
})
@@ -39,6 +39,7 @@
# Dependencies needed for running the checkPhase.
# These are added to buildInputs when doCheck = true.
, checkInputs ? []
, nativeCheckInputs ? []
# propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B
@@ -114,7 +115,7 @@ let
name_ = name;
self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [
"disabled" "checkPhase" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format"
"disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format"
"disabledTestPaths" "outputs"
]) // {
@@ -169,13 +170,14 @@ let
# Python packages don't have a checkPhase, only an installCheckPhase
doCheck = false;
doInstallCheck = attrs.doCheck or true;
installCheckInputs = [
nativeInstallCheckInputs = [
] ++ lib.optionals (format == "setuptools") [
# Longer-term we should get rid of this and require
# users of this function to set the `installCheckPhase` or
# pass in a hook that sets it.
setuptoolsCheckHook
] ++ checkInputs;
] ++ nativeCheckInputs;
installCheckInputs = checkInputs;
postFixup = lib.optionalString (!dontWrapPythonPrograms) ''
wrapPythonPrograms
@@ -41,8 +41,6 @@ let
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../../../build-support/build-setupcfg self;
fetchPypi = callPackage ./fetchpypi.nix { };
# Check whether a derivation provides a Python module.
hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
@@ -89,7 +87,7 @@ in {
inherit lib pkgs stdenv;
inherit (python.passthru) isPy27 isPy37 isPy38 isPy39 isPy310 isPy311 isPy3k isPyPy pythonAtLeast pythonOlder;
inherit buildPythonPackage buildPythonApplication;
inherit fetchPypi;
inherit (pkgs) fetchPypi;
inherit hasPythonModule requiredPythonModules makePythonPath disabled disabledIf;
inherit toPythonModule toPythonApplication;
inherit buildSetupcfg;
@@ -24,7 +24,7 @@ rustPlatform.buildRustPackage rec {
buildInputs = lib.optionals stdenv.isDarwin [ SystemConfiguration ];
checkInputs = [ python3 ];
nativeCheckInputs = [ python3 ];
meta = with lib; {
description = "Python 3 interpreter in written Rust";