Bug 247408 - misc/py-xgboost: python can't import xgboost.so
Summary: misc/py-xgboost: python can't import xgboost.so
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL: https://github.com/dmlc/xgboost/issue...
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-19 09:14 UTC by nomoo
Modified: 2020-10-27 01:45 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (yuri)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nomoo 2020-06-19 09:14:37 UTC
Testing 11.4, quarterly and latest pkgs(py37-xgboost 1.0.2 and 1.1.1):
====================   8<   =======================
python3.7
Python 3.7.7 (default, Jun 16 2020, 01:12:14)
[Clang 8.0.0 (tags/RELEASE_800/final 356365)] on freebsd11
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/xgboost/__init__.py", line 11, in <module>
    from .core import DMatrix, DeviceQuantileDMatrix, Booster
  File "/usr/local/lib/python3.7/site-packages/xgboost/core.py", line 175, in <module>
    _LIB = _load_lib()
  File "/usr/local/lib/python3.7/site-packages/xgboost/core.py", line 134, in _load_lib
    lib_paths = find_lib_path()
  File "/usr/local/lib/python3.7/site-packages/xgboost/libpath.py", line 45, in find_lib_path
    dll_path = [os.path.join(p, 'libxgboost.so') for p in dll_path]
  File "/usr/local/lib/python3.7/site-packages/xgboost/libpath.py", line 45, in <listcomp>
    dll_path = [os.path.join(p, 'libxgboost.so') for p in dll_path]
  File "/usr/local/lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
====================   8<   =======================

I used to solve it like this:
====================   8<   =======================
--- xgboost/libpath.py.orig	2020-03-02 05:10:11 UTC
+++ xgboost/libpath.py
@@ -4,6 +4,7 @@
 import os
 import platform
 import sys
+import sysconfig


 class XGBoostLibraryNotFound(Exception):
@@ -22,7 +23,8 @@ def find_lib_path():
     # make pythonpack hack: copy this directory one level upper for setup.py
     dll_path = [curr_path, os.path.join(curr_path, '../../lib/'),
                 os.path.join(curr_path, './lib/'),
-                os.path.join(sys.prefix, 'xgboost')]
+                os.path.join(sys.prefix, 'xgboost'),
+                sysconfig.get_config_var('LIBDIR')]
     if sys.platform == 'win32':
         if platform.architecture()[0] == '64bit':
             dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/'))
====================   8<   =======================
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2020-10-26 20:50:31 UTC
This appears to be a bug with the upstream code.

Added the upstream bug report.
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2020-10-26 20:58:58 UTC
nomoo,

Thank you for submitting the bug report.

The correct location to submit bugs in the projects themselves is their bug reporting systems, in this case - a GitHub issues page.

Yuri
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2020-10-26 21:38:35 UTC
The fix is included in the update to 1.2.1
Comment 4 commit-hook freebsd_committer freebsd_triage 2020-10-26 21:39:00 UTC
A commit references this bug:

Author: yuri
Date: Mon Oct 26 21:38:06 UTC 2020
New revision: 553389
URL: https://svnweb.freebsd.org/changeset/ports/553389

Log:
  misc/py-xgboost: Update 1.2.0 -> 1.2.1

  PR:		247408
  MFH:		2020Q4 (fixes py-xgboost failure, see bug#247408)

Changes:
  head/misc/py-xgboost/Makefile
  head/misc/py-xgboost/distinfo
  head/misc/py-xgboost/files/patch-CMakeLists.txt
  head/misc/py-xgboost/files/patch-xgboost_libpath.py
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-10-27 01:45:38 UTC
A commit references this bug:

Author: yuri
Date: Tue Oct 27 01:45:31 UTC 2020
New revision: 553406
URL: https://svnweb.freebsd.org/changeset/ports/553406

Log:
  MFH: r552175 r553388 r553389

  Now builds on FreeBSD-12 powerpc64.  As a test, also enable on FreeBSD-13 powerpc64.

  Approved by:	portmgr (tier-2 blanket)

  misc/xgboost: Update 1.2.0 -> 1.2.1

  misc/py-xgboost: Update 1.2.0 -> 1.2.1

  PR:		247408

  Approved by:	ports-secteam (fluffy)

Changes:
_U  branches/2020Q4/
  branches/2020Q4/misc/py-xgboost/Makefile
  branches/2020Q4/misc/py-xgboost/distinfo
  branches/2020Q4/misc/py-xgboost/files/patch-CMakeLists.txt
  branches/2020Q4/misc/py-xgboost/files/patch-xgboost_libpath.py
  branches/2020Q4/misc/xgboost/Makefile
  branches/2020Q4/misc/xgboost/distinfo