Bug 247408 - misc/py-xgboost: python can't import xgboost.so
Summary: misc/py-xgboost: python can't import xgboost.so
Status: New
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:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-19 09:14 UTC by nomoo
Modified: 2020-06-19 09:14 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<   =======================