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.
|
||||
from __future__ import absolute_import
|
||||
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_runtime import *
|
||||
from . import fastdeploy_main as C
|
||||
from . import vision
|
||||
from .download import download, download_and_decompress
|
||||
|
||||
|
||||
def TensorInfoStr(tensor_info):
|
||||
message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
|
||||
tensor_info.name, tensor_info.dtype, tensor_info.shape)
|
||||
@@ -103,5 +121,6 @@ def RuntimeOptionStr(runtime_option):
|
||||
message.strip("\n")
|
||||
message += ")"
|
||||
return message
|
||||
|
||||
C.TensorInfo.__repr__ = TensorInfoStr
|
||||
C.RuntimeOption.__repr__ = RuntimeOptionStr
|
@@ -1 +1,2 @@
|
||||
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",
|
||||
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":
|
||||
rpaths = ["$ORIGIN:$ORIGIN/libs"]
|
||||
for root, dirs, files in os.walk(
|
||||
|
Reference in New Issue
Block a user