Numpy 2 is broken
Closed this issue · 4 comments
Describe the issue
A project that contains numpy 2 fails to build given numpy 2 has no setup.py
. Numpy 2 has a pyproject.toml instead. The error is as follow:
last 10 log lines:
> Executing setuptoolsBuildPhase
> Traceback (most recent call last):
> File "/private/tmp/nix-build-python3.12-numpy-2.0.0.drv-0/numpy-2.0.0/nix_run_setup", line 8, in <module>
> exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/nix/store/65ackbgqn02p6fy75rksjbp17zj6440j-python3-3.12.3/lib/python3.12/tokenize.py", line 449, in open
> buffer = _builtin_open(filename, 'rb')
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> FileNotFoundError: [Errno 2] No such file or directory: 'setup.py'
> /nix/store/ashgigyp2dkvfi1spyl9nsnirvbk67vh-stdenv-darwin/setup: line 1588: pop_var_context: head of shell_variables not a function context
For full logs, run 'nix log /nix/store/mv91j1n604svgjwqb6mcas9ykczf9z6c-python3.12-numpy-2.0.0.drv'.
default.nix
/shell.nix
/flake.nix
:
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
{
packages = {
myapp = mkPoetryApplication {
projectDir = self;
python=pkgs.python312;
};
};
defaultPackage = self.packages.${system}.myapp;
# Shell for app dependencies.
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.myapp ];
};
# Shell for poetry.
devShells.poetry = pkgs.mkShell {
packages = [ pkgs.poetry ];
};
});
}
pyproject.toml
:
[tool.poetry]
name = "tradesim"
version = "0.1.0"
description = "Algorithmic trading simulator"
authors = ["ashkan-leo <ashkan.aleali@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
numpy = "^2.0.0"
pandas = "^2.2.2"
matplotlib = "^3.9.0"
seaborn = "^0.13.2"
jupyterlab = "^4.2.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Any advise on how to fix the issue?
It seems to be slightly more involved then sticking 'meson-python' into the build-sytem overrides, I tried :(.
Edit: Ah yes, it's overwritten in overrides/default.nix.
PR incoming.
Till the PR is merged, you can use my branch at https://github.com/TyberiusPrime/poetry2nix/numpy2 in your flake.nix to get unblocked.
Alternatively, you can use wheels via preferWheels = true
(causes everything to prefer wheels), or set preferWheel = true
for only numpy.
At least for me, preferWheel does not lead the wheel being used (preferWheels does though). And yes, I'm using override.