Skip to content

Commit

Permalink
Merge pull request #15 from flamhaze5946/flamhaze5946
Browse files Browse the repository at this point in the history
improve environment prepare step
  • Loading branch information
mn3711698 authored Nov 4, 2021
2 parents 1c3b972 + 9a51e3c commit 80dc081
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 24 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ dmypy.json
.pyre/


.idea/
.idea/

gmlog_print.txt
strategies/base.pyd
strategies/base.so
71 changes: 48 additions & 23 deletions strategies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,55 @@
##############################################################################
# linux支持python3.6 windows支持64位python3.8,python3.7
import platform
import shutil
import os

if platform.system() == 'Windows':
if '3.8' in platform.python_version():
try:
from .base import Base
dll_map = {
'Windows': {
'pyv_dll_map': {
'3.7': 'base_w37.pyd',
'3.8': 'base_w38.pyd',
},
'target_dll_name': 'base.pyd'
},
'Linux': {
'pyv_dll_map': {
'3.6': 'base_l36.so'
},
'target_dll_name': 'base.so'
}
}

except Exception as e:
raise ValueError("请将本目前下的base_w38重命名为base替换原来的base")
elif '3.7' in platform.python_version():
try:
from .base import Base
platform_type = platform.system()
python_version = platform.python_version()

except Exception as e:
raise ValueError("请将本目前下的base_w37重命名为base替换原来的base")
else:
raise ValueError("python版本未提供支持")
elif platform.system() == 'Linux':
if '3.6' in platform.python_version():
try:
from .base import Base

except Exception as e:
raise ValueError("请将本目前下的base_l36.so重命名为base.so替换原来的base.so")
else:
raise ValueError("python版本未提供支持")
else:
if platform_type not in dll_map:
raise ValueError("操作系统未提供支持")

platform_dll_map = dll_map[platform_type]
pyv_dll_map = platform_dll_map['pyv_dll_map']

dll_name = None
for python_version_prefix in pyv_dll_map:
if python_version.startswith(python_version_prefix):
dll_name = pyv_dll_map[python_version_prefix]
break

if dll_name is None:
raise ValueError("python版本未提供支持")

target_dll_name = platform_dll_map['target_dll_name']

load_path = os.path.abspath(os.path.dirname(__file__))
candidate_dll_path = os.path.join(load_path, dll_name)
target_dll_path = os.path.join(load_path, target_dll_name)

candidate_dll_exists = os.path.isfile(candidate_dll_path)
target_dll_exists = os.path.isfile(target_dll_path)
if not target_dll_exists:
if not candidate_dll_exists:
raise ValueError("策略文件加载失败, 请重新下载项目或联系作者")
else:
shutil.copyfile(candidate_dll_path, target_dll_path)

from .base import Base

0 comments on commit 80dc081

Please sign in to comment.