From 875bb6bcb98de45bcc54c50cf4428ca9e3b1f7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Mon, 3 Sep 2018 15:47:04 +0200 Subject: [PATCH 1/3] vowpalwabbit: fix build against boost-python. Patch setup.py to look for libboost_python{Major}{Minor}. --- .../python-modules/vowpalwabbit/default.nix | 9 ++++++++- .../vowpalwabbit/vowpal-wabbit-find-boost.diff | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff diff --git a/pkgs/development/python-modules/vowpalwabbit/default.nix b/pkgs/development/python-modules/vowpalwabbit/default.nix index a8661fd3a985..6ee6e42e97d9 100644 --- a/pkgs/development/python-modules/vowpalwabbit/default.nix +++ b/pkgs/development/python-modules/vowpalwabbit/default.nix @@ -9,13 +9,20 @@ buildPythonPackage rec { inherit pname version; sha256 = "0b517371fc64f1c728a0af42a31fa93def27306e9b4d25d6e5fd01bcff1b7304"; }; + + # Should be fixed in next Python release after 8.5.0: + # https://github.com/JohnLangford/vowpal_wabbit/pull/1533 + patches = [ + ./vowpal-wabbit-find-boost.diff + ]; + # vw tries to write some explicit things to home # python installed: The directory '/homeless-shelter/.cache/pip/http' preInstall = '' export HOME=$PWD ''; - buildInputs = [ boost.dev zlib.dev clang ncurses pytest docutils pygments ]; + buildInputs = [ python.pkgs.boost zlib.dev clang ncurses pytest docutils pygments ]; propagatedBuildInputs = [ numpy scipy scikitlearn ]; checkPhase = '' diff --git a/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff b/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff new file mode 100644 index 000000000000..0e7b13c01030 --- /dev/null +++ b/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff @@ -0,0 +1,16 @@ +--- vowpalwabbit-8.5.0.orig/setup.py 2018-09-03 14:27:22.833621339 +0200 ++++ vowpalwabbit-8.5.0/setup.py 2018-09-03 14:37:18.076127914 +0200 +@@ -25,12 +25,7 @@ + """Find correct boost-python library information """ + if system == 'Linux': + # use version suffix if present +- boost_lib = 'boost_python-py{v[0]}{v[1]}'.format(v=sys.version_info) +- if sys.version_info.major == 3: +- for candidate in ['-py36', '-py35', '-py34', '3']: +- boost_lib = 'boost_python{}'.format(candidate) +- if find_library(boost_lib): +- exit ++ boost_lib = 'boost_python{v[0]}{v[1]}'.format(v=sys.version_info) + if not find_library(boost_lib): + boost_lib = "boost_python" + elif system == 'Darwin': From fe7e89ba3b57b6d3a75fd0b7d08f13ba98f79700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Mon, 3 Sep 2018 21:48:13 +0200 Subject: [PATCH 2/3] vowpal-wabbit: fix Darwin build. - Follow the same logic for finding boost-python as for Linux. - Set DYLD_LIBRARY_PATH so that ctypes find_library can find boost-python. - Do not use '-mt' suffix when linking against boost-serialization and boost-program_options on Darwin. --- .../python-modules/vowpalwabbit/default.nix | 9 ++++-- .../vowpal-wabbit-find-boost.diff | 28 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/vowpalwabbit/default.nix b/pkgs/development/python-modules/vowpalwabbit/default.nix index 6ee6e42e97d9..6530ce28a9e3 100644 --- a/pkgs/development/python-modules/vowpalwabbit/default.nix +++ b/pkgs/development/python-modules/vowpalwabbit/default.nix @@ -1,5 +1,5 @@ -{ lib, buildPythonPackage, fetchPypi, python, boost, zlib, clang, ncurses -, pytest, docutils, pygments, numpy, scipy, scikitlearn }: +{ stdenv, lib, buildPythonPackage, fetchPypi, python, boost, zlib, clang +, ncurses, pytest, docutils, pygments, numpy, scipy, scikitlearn }: buildPythonPackage rec { pname = "vowpalwabbit"; @@ -25,6 +25,11 @@ buildPythonPackage rec { buildInputs = [ python.pkgs.boost zlib.dev clang ncurses pytest docutils pygments ]; propagatedBuildInputs = [ numpy scipy scikitlearn ]; + # Python ctypes.find_library uses DYLD_LIBRARY_PATH. + preConfigure = lib.optionalString stdenv.isDarwin '' + export DYLD_LIBRARY_PATH="${python.pkgs.boost}/lib" + ''; + checkPhase = '' # check-manifest requires a git clone, not a tarball # check-manifest --ignore "Makefile,PACKAGE.rst,*.cc,tox.ini,tests*,examples*,src*" diff --git a/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff b/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff index 0e7b13c01030..645956594bf6 100644 --- a/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff +++ b/pkgs/development/python-modules/vowpalwabbit/vowpal-wabbit-find-boost.diff @@ -1,8 +1,11 @@ ---- vowpalwabbit-8.5.0.orig/setup.py 2018-09-03 14:27:22.833621339 +0200 -+++ vowpalwabbit-8.5.0/setup.py 2018-09-03 14:37:18.076127914 +0200 -@@ -25,12 +25,7 @@ +--- vowpalwabbit-8.5.0.orig/setup.py 2018-09-03 20:32:39.000000000 +0200 ++++ vowpalwabbit-8.5.0/setup.py 2018-09-03 20:34:09.000000000 +0200 +@@ -23,18 +23,11 @@ + + def find_boost(): """Find correct boost-python library information """ - if system == 'Linux': +- if system == 'Linux': ++ if system == 'Linux' or system == 'Darwin': # use version suffix if present - boost_lib = 'boost_python-py{v[0]}{v[1]}'.format(v=sys.version_info) - if sys.version_info.major == 3: @@ -13,4 +16,19 @@ + boost_lib = 'boost_python{v[0]}{v[1]}'.format(v=sys.version_info) if not find_library(boost_lib): boost_lib = "boost_python" - elif system == 'Darwin': +- elif system == 'Darwin': +- boost_lib = 'boost_python-mt' if sys.version_info[0] == 2 else 'boost_python3-mt' + elif system == 'Cygwin': + boost_lib = 'boost_python-mt' if sys.version_info[0] == 2 else 'boost_python3-mt' + else: +--- vowpalwabbit-8.5.0.orig/src/Makefile 2018-09-03 20:32:40.000000000 +0200 ++++ vowpalwabbit-8.5.0/src/Makefile 2018-09-03 21:42:30.000000000 +0200 +@@ -37,7 +37,7 @@ + NPROCS:=$(shell grep -c ^processor /proc/cpuinfo) + endif + ifeq ($(UNAME), Darwin) +- LIBS = -lboost_program_options-mt -lboost_serialization-mt -l pthread -l z ++ LIBS = -lboost_program_options -lboost_serialization -l pthread -l z + # On Macs, the location isn't always clear + # brew uses /usr/local + # but /opt/local seems to be preferred by some users From 69d418aeac5e56e3cf7752cc22290fd35ee9c4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Tue, 4 Sep 2018 07:43:53 +0200 Subject: [PATCH 3/3] vowpalwabbit: mark broken on aarch64. --- pkgs/development/python-modules/vowpalwabbit/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/python-modules/vowpalwabbit/default.nix b/pkgs/development/python-modules/vowpalwabbit/default.nix index 6530ce28a9e3..9bc2bbc27047 100644 --- a/pkgs/development/python-modules/vowpalwabbit/default.nix +++ b/pkgs/development/python-modules/vowpalwabbit/default.nix @@ -40,6 +40,7 @@ buildPythonPackage rec { description = "Vowpal Wabbit is a fast machine learning library for online learning, and this is the python wrapper for the project."; homepage = https://github.com/JohnLangford/vowpal_wabbit; license = licenses.bsd3; + broken = stdenv.isAarch64; maintainers = with maintainers; [ teh ]; }; }