Коммит
7da0274a42
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding:utf8
|
# coding:utf8
|
||||||
|
|
||||||
from api import init, shutdown, barrier, workers_num, worker_id, server_id, is_master_worker
|
from .api import init, shutdown, barrier, workers_num, worker_id, server_id, is_master_worker
|
||||||
from tables import ArrayTableHandler, MatrixTableHandler
|
from .tables import ArrayTableHandler, MatrixTableHandler
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# coding:utf8
|
# coding:utf8
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
from utils import Loader
|
from .utils import Loader
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ def init(sync=False):
|
||||||
`barrier` and `get` with the argument `sync` set to `True` to sync the
|
`barrier` and `get` with the argument `sync` set to `True` to sync the
|
||||||
processes.
|
processes.
|
||||||
'''
|
'''
|
||||||
args = [""] # the first argument will be ignored. So we put a placeholder here
|
args = [b""] # the first argument will be ignored. So we put a placeholder here
|
||||||
if sync:
|
if sync:
|
||||||
args.append("-sync=true")
|
args.append(b"-sync=true")
|
||||||
n = len(args)
|
n = len(args)
|
||||||
args_type = ctypes.c_char_p * n
|
args_type = ctypes.c_char_p * n
|
||||||
mv_lib.MV_Init(ctypes.pointer(ctypes.c_int(n)), args_type(*[ctypes.c_char_p(arg) for arg in args]))
|
mv_lib.MV_Init(ctypes.pointer(ctypes.c_int(n)), args_type(*[ctypes.c_char_p(arg) for arg in args]))
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# coding:utf8
|
# coding:utf8
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
from utils import Loader
|
from .utils import Loader
|
||||||
from utils import convert_data
|
from .utils import convert_data
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import api
|
from . import api
|
||||||
|
|
||||||
|
|
||||||
mv_lib = Loader.get_lib()
|
mv_lib = Loader.get_lib()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding:utf8
|
# coding:utf8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
@ -23,31 +25,31 @@ class Loader(object):
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
mv_lib_path = find_library("Multiverso")
|
mv_lib_path = find_library("Multiverso")
|
||||||
if mv_lib_path is None:
|
if mv_lib_path is None:
|
||||||
print "* Fail to load Multiverso.dll from the windows $PATH."\
|
print("* Fail to load Multiverso.dll from the windows $PATH."\
|
||||||
"Because Multiverso.dll can not be found in the $PATH "\
|
"Because Multiverso.dll can not be found in the $PATH "\
|
||||||
"directories. Go on loading Multiverso from the package."
|
"directories. Go on loading Multiverso from the package.")
|
||||||
else:
|
else:
|
||||||
return mv_lib_path
|
return mv_lib_path
|
||||||
|
|
||||||
mv_lib_path = os.path.join(PACKAGE_PATH, "Multiverso.dll")
|
mv_lib_path = os.path.join(PACKAGE_PATH, "Multiverso.dll")
|
||||||
if not os.path.exists(mv_lib_path):
|
if not os.path.exists(mv_lib_path):
|
||||||
print "* Fail to load Multiverso.dll from the package. Because"\
|
print("* Fail to load Multiverso.dll from the package. Because"\
|
||||||
" the file " + mv_lib_path + " can not be found."
|
" the file " + mv_lib_path + " can not be found.")
|
||||||
else:
|
else:
|
||||||
return mv_lib_path
|
return mv_lib_path
|
||||||
else:
|
else:
|
||||||
mv_lib_path = find_library("multiverso")
|
mv_lib_path = find_library("multiverso")
|
||||||
if mv_lib_path is None:
|
if mv_lib_path is None:
|
||||||
print "* Fail to load libmultiverso.so from the system"\
|
print("* Fail to load libmultiverso.so from the system"\
|
||||||
"libraries. Because libmultiverso.so can't be found in"\
|
"libraries. Because libmultiverso.so can't be found in"\
|
||||||
"library paths. Go on loading Multiverso from the package."
|
"library paths. Go on loading Multiverso from the package.")
|
||||||
else:
|
else:
|
||||||
return mv_lib_path
|
return mv_lib_path
|
||||||
|
|
||||||
mv_lib_path = os.path.join(PACKAGE_PATH, "libmultiverso.so")
|
mv_lib_path = os.path.join(PACKAGE_PATH, "libmultiverso.so")
|
||||||
if not os.path.exists(mv_lib_path):
|
if not os.path.exists(mv_lib_path):
|
||||||
print "* Fail to load libmultiverso.so from the package. Because"\
|
print("* Fail to load libmultiverso.so from the package. Because"\
|
||||||
" the file " + mv_lib_path + " can not be found."
|
" the file " + mv_lib_path + " can not be found.")
|
||||||
else:
|
else:
|
||||||
return mv_lib_path
|
return mv_lib_path
|
||||||
return None
|
return None
|
||||||
|
@ -56,10 +58,10 @@ class Loader(object):
|
||||||
def load_lib(cls):
|
def load_lib(cls):
|
||||||
mv_lib_path = cls._find_mv_path()
|
mv_lib_path = cls._find_mv_path()
|
||||||
if mv_lib_path is None:
|
if mv_lib_path is None:
|
||||||
print "Fail to load the multiverso library. Please make sure you"\
|
print("Fail to load the multiverso library. Please make sure you"\
|
||||||
" have installed multiverso successfully"
|
" have installed multiverso successfully")
|
||||||
else:
|
else:
|
||||||
print "Find the multiverso library successfully(%s)" % mv_lib_path
|
print("Find the multiverso library successfully(%s)" % mv_lib_path)
|
||||||
return ctypes.cdll.LoadLibrary(mv_lib_path)
|
return ctypes.cdll.LoadLibrary(mv_lib_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Загрузка…
Ссылка в новой задаче