Skip to content

Commit

Permalink
python312Packages.numpy_2: 2.0.1 -> 2.1.0 (#336284)
Browse files Browse the repository at this point in the history
  • Loading branch information
doronbehar authored Aug 26, 2024
2 parents ddc93e1 + 4865fc4 commit 3188db0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 49 deletions.
23 changes: 11 additions & 12 deletions pkgs/development/python-modules/llvmlite/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
setuptools,

# tests
python,
pytestCheckHook,
}:

buildPythonPackage rec {
Expand All @@ -33,34 +33,33 @@ buildPythonPackage rec {
setuptools
];

# Disable static linking
# https://github.com/numba/llvmlite/issues/93
postPatch = ''
substituteInPlace ffi/Makefile.linux --replace "-static-libstdc++" ""
substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope"
substituteInPlace llvmlite/tests/test_binding.py \
--replace-fail "test_linux" "nope"
'';

# Set directory containing llvm-config binary
preConfigure = ''
export LLVM_CONFIG=${llvm.dev}/bin/llvm-config
'';

checkPhase = ''
runHook preCheck
${python.executable} runtests.py
runHook postCheck
nativeCheckInputs = [
pytestCheckHook
];
# https://github.com/NixOS/nixpkgs/issues/255262
preCheck = ''
cd $out
'';

__impureHostDeps = lib.optionals stdenv.isDarwin [ "/usr/lib/libm.dylib" ];

passthru.llvm = llvm;

meta = with lib; {
meta = {
changelog = "https://github.com/numba/llvmlite/blob/v${version}/CHANGE_LOG";
description = "Lightweight LLVM python binding for writing JIT compilers";
downloadPage = "https://github.com/numba/llvmlite";
homepage = "http://llvmlite.pydata.org/";
license = licenses.bsd2;
license = lib.licenses.bsd2;
};
}
86 changes: 51 additions & 35 deletions pkgs/development/python-modules/numba/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
python,
buildPythonPackage,
setuptools,
numpy,
numpy_2,
llvmlite,
libcxx,
Expand All @@ -17,6 +16,7 @@
runCommand,
writers,
numba,
pytestCheckHook,

config,

Expand All @@ -27,13 +27,15 @@

# CUDA flags:
cudaSupport ? config.cudaSupport,
testsWithoutSandbox ? false,
doFullCheck ? false,
}:

let
cudatoolkit = cudaPackages.cuda_nvcc;
in
buildPythonPackage rec {
version = "0.60.0";
version = "0.61.0dev0";
pname = "numba";
pyproject = true;

Expand All @@ -54,8 +56,18 @@ buildPythonPackage rec {
# that upstream relies on those strings to be valid, that's why we don't
# use `forceFetchGit = true;`.` If in the future we'll observe the hash
# changes too often, we can always use forceFetchGit, and inject the
# relevant strings ourselves, using `sed` commands, in extraPostFetch.
hash = "sha256-hUL281wHLA7wo8umzBNhiGJikyIF2loCzjLECuC+pO0=";
# relevant strings ourselves, using `substituteInPlace`, in postFetch.
hash = "sha256-KF9YQ6/FIfUQTJCAMgfIqnb/D8mdMbCC/tJvfYlSkgI=";
# TEMPORARY: The way upstream knows it's source version is explained above,
# and without this upstream sets the version in ${python.sitePackages} as
# 0.61.0dev0, which causes dependent packages fail to find a valid
# version of numba.
postFetch = ''
substituteInPlace $out/numba/_version.py \
--replace-fail \
'git_refnames = " (tag: ${version})"' \
'git_refnames = " (tag: 0.61.0, release0.61)"'
'';
};

postPatch = ''
Expand All @@ -69,18 +81,19 @@ buildPythonPackage rec {

build-system = [
setuptools
numpy_2
];

nativeBuildInputs = lib.optionals cudaSupport [
autoAddDriverRunpath
cudaPackages.cuda_nvcc
];

buildInputs = lib.optionals cudaSupport [ cudaPackages.cuda_cudart ];
buildInputs = [
# Not propagating it, because it numba can work with either numpy_2 or numpy_1
numpy_2
] ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ];

dependencies = [
numpy
llvmlite
setuptools
] ++ lib.optionals (pythonOlder "3.9") [ importlib-metadata ];
Expand All @@ -103,20 +116,28 @@ buildPythonPackage rec {
})
];

# run a smoke test in a temporary directory so that
# a) Python picks up the installed library in $out instead of the build files
# b) we have somewhere to put $HOME so some caching tests work
# c) it doesn't take 6 CPU hours for the full suite
checkPhase = ''
runHook preCheck
pushd $(mktemp -d)
HOME=. ${python.interpreter} -m numba.runtests -m $NIX_BUILD_CORES numba.tests.test_usecases
popd
nativeCheckInputs = [
pytestCheckHook
];

runHook postCheck
preCheck = ''
export HOME="$(mktemp -d)"
# https://github.com/NixOS/nixpkgs/issues/255262
cd $out
'';

pytestFlagsArray = lib.optionals (!doFullCheck) [
# These are the most basic tests. Running all tests is too expensive, and
# some of them fail (also differently on different platforms), so it will
# be too hard to maintain such a `disabledTests` list.
"${python.sitePackages}/numba/tests/test_usecases.py"
];

disabledTestPaths = lib.optionals (!testsWithoutSandbox) [
# See NOTE near passthru.tests.withoutSandbox
"${python.sitePackages}/numba/cuda/tests"
];

pythonImportsCheck = [ "numba" ];

passthru.testers.cuda-detect =
Expand All @@ -128,23 +149,18 @@ buildPythonPackage rec {
'';
passthru.tests = {
# CONTRIBUTOR NOTE: numba also contains CUDA tests, though these cannot be run in
# this sandbox environment. Consider running similar commands to those below outside the
# sandbox manually if you have the appropriate hardware; support will be detected
# and the corresponding tests enabled automatically.
# Also, the full suite currently does not complete on anything but x86_64-linux.
fullSuite = runCommand "${pname}-test" { } ''
pushd $(mktemp -d)
# pip and python in $PATH is needed for the test suite to pass fully
PATH=${
python.withPackages (p: [
p.numba
p.pip
])
}/bin:$PATH
HOME=$PWD python -m numba.runtests -m $NIX_BUILD_CORES
popd
touch $out # stop Nix from complaining no output was generated and failing the build
'';
# this sandbox environment. Consider building the derivation below with
# --no-sandbox to get a view of how many tests succeed outside the sandbox.
withoutSandbox = numba.override {
doFullCheck = true;
cudaSupport = true;
testsWithoutSandbox = true;
};
withSandbox = numba.override {
cudaSupport = false;
doFullCheck = true;
testsWithoutSandbox = false;
};
};

meta = with lib; {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/numpy/2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ let
in
buildPythonPackage rec {
pname = "numpy";
version = "2.0.1";
version = "2.1.0";
pyproject = true;

disabled = pythonOlder "3.10";

src = fetchPypi {
inherit pname version;
extension = "tar.gz";
hash = "sha256-SFuHI1eWQQw1GaaZz+H6qwl+UJ6Q67BdzQmNsq6H57M=";
hash = "sha256-fckNoAgffh2knsTjmO3mqOnMT16+X54GtEPtiJ7pqqI=";
};

patches = lib.optionals python.hasDistutilsCxxPatch [
Expand Down

0 comments on commit 3188db0

Please sign in to comment.