Hi,
I am trying to build a scikit learn from their GitHub repo. Loading Scikit learn using the nix python package works without issues, but I want to have my own development version. I am very new to this, so I am not even sure if I am on the right track. So far, I have made a nix-shell with some dependencies mostly based on nixpkgs/doc/languages-frameworks/python.section.md at 346de1fb8c3273ea74a0d15ff0580b0d6610a476 · NixOS/nixpkgs · GitHub
with import <nixpkgs> { };
let
py = python312Packages;
in pkgs.mkShell rec {
name = "impurePythonEnv";
venvDir = "./.venv";
propagatedBuildInputs = [
# A python interpreter including the 'venv' module is required to bootstrap
# the environment.
py.python
# This execute some shell code to initialize a venv in $venvDir before
# dropping into the shell
py.venvShellHook
# Those are dependencies that we would like to use from nixpkgs, which will
# add them to PYTHONPATH and thus make them accessible from within the venv.
py.numpy
py.scipy
py.joblib
py.threadpoolctl
py.cython
py.meson-python
py.ninja
py.pytest
py.setuptools
py.wheel
#py.pillow
#py.pythonRelaxDepsHook
# In this particular example, in order to compile any binary extensions they may
# require, the python modules listed in the hypothetical requirements.txt need
# the following packages to be installed locally:
git
gcc
libgcc
glibc
gfortran
stdenv.cc.cc
glibcLocales
];
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib";
}
and then try following the sklearn documentation to build it with pip, either as
pip install --editable . --verbose --no-build-isolation --config-settings editable-verbose=true --upgrade
or
pip install -e .
There, it will fail on a compilation step with a very long and, for me, not understandable error dump.
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing editable metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [110 lines of output]
+ meson setup --reconfigure /home/brick/Code/scikit-learn /home/brick/Code/scikit-learn/build/cp312 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/home/brick/Code/scikit-learn/build/cp312/meson-python-native-file.ini
Cleaning... 0 files.
WARNING: Regenerating configuration from scratch.
Reason: Coredata file '/home/brick/Code/scikit-learn/build/cp312/meson-private/coredata.dat' references functions or classes that don't exist. This probably means that it was generated with an old version of meson.
The Meson build system
Version: 1.5.1
Source dir: /home/brick/Code/scikit-learn
Build dir: /home/brick/Code/scikit-learn/build/cp312
Build type: native build
Project name: scikit-learn
Project version: 1.6.dev0
C compiler for the host machine: gcc (gcc 13.2.0 "gcc (GCC) 13.2.0")
C linker for the host machine: gcc ld.bfd 2.41
C++ compiler for the host machine: g++ (gcc 13.2.0 "g++ (GCC) 13.2.0")
C++ linker for the host machine: g++ ld.bfd 2.41
Cython compiler for the host machine: cython (cython 3.0.10)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-but-set-variable: YES
Compiler for C supports arguments -Wno-unused-function: YES
Compiler for C supports arguments -Wno-conversion: YES
Compiler for C supports arguments -Wno-misleading-indentation: YES
Library m found: YES
Program python found: YES (/home/brick/Code/scikit-learn/.venv/bin/python3.12)
Run-time dependency OpenMP for c found: YES 4.5
Did not find pkg-config by name 'pkg-config'
Found pkg-config: NO
Run-time dependency python found: YES 3.12
Build targets in project: 111
scikit-learn 1.6.dev0
User defined options
Native files: /home/brick/Code/scikit-learn/build/cp312/meson-python-native-file.ini
buildtype : release
b_ndebug : if-release
b_vscrt : md
Found ninja-1.11.1 at /nix/store/p5y20shjad8an1jhcby82sz843lirvwi-ninja-1.11.1/bin/ninja
+ /nix/store/p5y20shjad8an1jhcby82sz843lirvwi-ninja-1.11.1/bin/ninja
[1/145] Linking target sklearn/ensemble/_hist_gradient_boosting/histogram.cpython-312-x86_64-linux-gnu.so
FAILED: sklearn/ensemble/_hist_gradient_boosting/histogram.cpython-312-x86_64-linux-gnu.so
gcc -o sklearn/ensemble/_hist_gradient_boosting/histogram.cpython-312-x86_64-linux-gnu.so sklearn/ensemble/_hist_gradient_boosting/histogram.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_ensemble__hist_gradient_boosting_histogram.pyx.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -Wl,-O1 -shared -fPIC -lm -fopenmp
/nix/store/7v7g86ml0ri171gfcrs1d442px5bi1p3-binutils-2.41/bin/ld: /nix/store/llmjvk4i2yncv8xqdvs4382wr3kgdmvp-gcc-13.2.0/lib/libgomp.a(barrier.o): relocation R_X86_64_TPOFF32 against hidden symbol `gomp_tls_data' can not be used when making a shared object
/nix/store/7v7g86ml0ri171gfcrs1d442px5bi1p3-binutils-2.41/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
[2/145] Copying file sklearn/utils/_typedefs.pxd
[3/145] Copying file sklearn/utils/_heap.pxd
[4/145] Copying file sklearn/utils/_random.pxd
[5/145] Copying file sklearn/utils/_sorting.pxd
[6/145] Copying file sklearn/utils/_vector_sentinel.pxd
[7/145] Copying file sklearn/metrics/__init__.py
[8/145] Copying file sklearn/metrics/_pairwise_distances_reduction/_classmode.pxd
[9/145] Copying file sklearn/__init__.py
[10/145] Copying file sklearn/utils/_openmp_helpers.pxd
[11/145] Copying file sklearn/metrics/_pairwise_distances_reduction/__init__.py
[12/145] Copying file sklearn/utils/__init__.py
[13/145] Copying file sklearn/utils/_cython_blas.pxd
[14/121] Copying file sklearn/_loss/_loss.pxd
[15/117] Compiling C object sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_cluster__hdbscan__reachability.pyx.c.o
FAILED: sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_cluster__hdbscan__reachability.pyx.c.o
gcc -Isklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p -Isklearn/cluster/_hdbscan -I../../sklearn/cluster/_hdbscan -I../../../../../../tmp/pip-build-env-m39z5bzz/overlay/lib/python3.12/site-packages/numpy/_core/include -I/nix/store/k5i0778pfpqazsms6bk1pkmqc4bkq57n-python3-3.12.4/include/python3.12 -fvisibility=hidden -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -O3 -Wno-unused-but-set-variable -Wno-unused-function -Wno-conversion -Wno-misleading-indentation -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -MD -MQ sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_cluster__hdbscan__reachability.pyx.c.o -MF sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_cluster__hdbscan__reachability.pyx.c.o.d -o sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/meson-generated_sklearn_cluster__hdbscan__reachability.pyx.c.o -c sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/sklearn/cluster/_hdbscan/_reachability.pyx.c
In file included from /nix/store/k5i0778pfpqazsms6bk1pkmqc4bkq57n-python3-3.12.4/include/python3.12/Python.h:38,
from sklearn/cluster/_hdbscan/_reachability.cpython-312-x86_64-linux-gnu.so.p/sklearn/cluster/_hdbscan/_reachability.pyx.c:16:
Any idea how to make it work?