mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00
Fix python usage on Windows (#60)
* Polish compilation on Windows * Fix python usage on Windows
This commit is contained in:
@@ -13,13 +13,31 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def add_dll_search_dir(dir_path):
|
||||||
|
os.environ["path"] = dir_path + ";" + os.environ["path"]
|
||||||
|
sys.path.insert(0, dir_path)
|
||||||
|
if sys.version_info[:2] >= (3, 8):
|
||||||
|
os.add_dll_directory(dir_path)
|
||||||
|
|
||||||
|
if os.name == "nt":
|
||||||
|
current_path = os.path.abspath(__file__)
|
||||||
|
dirname = os.path.dirname(current_path)
|
||||||
|
third_libs_dir = os.path.join(dirname, "libs")
|
||||||
|
add_dll_search_dir(third_libs_dir)
|
||||||
|
for root, dirs, filenames in os.walk(third_libs_dir):
|
||||||
|
for d in dirs:
|
||||||
|
if d == "lib":
|
||||||
|
add_dll_search_dir(os.path.join(dirname, root, d))
|
||||||
|
|
||||||
from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, Device
|
from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, Device
|
||||||
from .fastdeploy_runtime import *
|
from .fastdeploy_runtime import *
|
||||||
from . import fastdeploy_main as C
|
from . import fastdeploy_main as C
|
||||||
from . import vision
|
from . import vision
|
||||||
from .download import download, download_and_decompress
|
from .download import download, download_and_decompress
|
||||||
|
|
||||||
|
|
||||||
def TensorInfoStr(tensor_info):
|
def TensorInfoStr(tensor_info):
|
||||||
message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
|
message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
|
||||||
tensor_info.name, tensor_info.dtype, tensor_info.shape)
|
tensor_info.name, tensor_info.dtype, tensor_info.shape)
|
||||||
@@ -28,7 +46,7 @@ def TensorInfoStr(tensor_info):
|
|||||||
|
|
||||||
class RuntimeOption:
|
class RuntimeOption:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._option = C.RuntimeOption()
|
self._option = C.RuntimeOption()
|
||||||
|
|
||||||
def set_model_path(self, model_path, params_path="", model_format="paddle"):
|
def set_model_path(self, model_path, params_path="", model_format="paddle"):
|
||||||
return self._option.set_model_path(model_path, params_path, model_format)
|
return self._option.set_model_path(model_path, params_path, model_format)
|
||||||
@@ -103,5 +121,6 @@ def RuntimeOptionStr(runtime_option):
|
|||||||
message.strip("\n")
|
message.strip("\n")
|
||||||
message += ")"
|
message += ")"
|
||||||
return message
|
return message
|
||||||
|
|
||||||
C.TensorInfo.__repr__ = TensorInfoStr
|
C.TensorInfo.__repr__ = TensorInfoStr
|
||||||
C.RuntimeOption.__repr__ = RuntimeOptionStr
|
C.RuntimeOption.__repr__ = RuntimeOptionStr
|
@@ -1 +1,2 @@
|
|||||||
requests
|
requests
|
||||||
|
tqdm
|
10
setup.py
10
setup.py
@@ -362,6 +362,16 @@ if sys.argv[1] == "install" or sys.argv[1] == "bdist_wheel":
|
|||||||
"fastdeploy/libs/third_libs",
|
"fastdeploy/libs/third_libs",
|
||||||
symlinks=True)
|
symlinks=True)
|
||||||
|
|
||||||
|
if platform.system().lower() == "windows":
|
||||||
|
release_dir = os.path.join(".setuptools-cmake-build", "Release")
|
||||||
|
for f in os.listdir(release_dir):
|
||||||
|
filename = os.path.join(release_dir, f)
|
||||||
|
if not os.path.isfile(filename):
|
||||||
|
continue
|
||||||
|
if filename.endswith(".pyd"):
|
||||||
|
continue
|
||||||
|
shutil.copy(filename, "fastdeploy/libs")
|
||||||
|
|
||||||
if platform.system().lower() == "linux":
|
if platform.system().lower() == "linux":
|
||||||
rpaths = ["$ORIGIN:$ORIGIN/libs"]
|
rpaths = ["$ORIGIN:$ORIGIN/libs"]
|
||||||
for root, dirs, files in os.walk(
|
for root, dirs, files in os.walk(
|
||||||
|
Reference in New Issue
Block a user