fix windows virtual env bug

This commit is contained in:
Dun Liang 2023-04-04 19:30:22 +08:00
parent 3bcdfc97a9
commit 5cf9c10c92
3 changed files with 24 additions and 9 deletions

View File

@ -9,7 +9,7 @@
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
__version__ = '1.3.7.7'
__version__ = '1.3.7.8'
from jittor_utils import lock
with lock.lock_scope():
ori_int = int

View File

@ -1098,10 +1098,7 @@ if os.name == 'nt':
if cc_type == 'g++':
pass
elif cc_type == 'cl':
py3_link_path = os.path.join(
os.path.dirname(sys.executable),
"libs",
)
py3_link_path = jit_utils.get_py3_link_path()
cc_flags = remove_flags(cc_flags, ["-f", "-m"])
cc_flags = cc_flags.replace("-std=c++14", "-std=c++17")
cc_flags = cc_flags.replace("-lstdc++", "")

View File

@ -445,6 +445,20 @@ def get_cc_type(cc_path):
if "cl" in bname: return "cl"
LOG.f(f"Unknown cc type: {bname}")
def get_py3_link_path():
py3_link_path = os.path.join(
os.path.dirname(sys.executable),
"libs",
)
if not os.path.exists(py3_link_path):
candidate = [os.path.dirname(sys.executable)] + sys.path
for p in candidate:
p = os.path.join(p, "libs")
if os.path.exists(p):
py3_link_path = p
break
return py3_link_path
def get_py3_config_path():
global _py3_config_path
if _py3_config_path:
@ -502,10 +516,14 @@ def get_py3_include_path():
if os.name == 'nt':
# Windows
sys.executable = sys.executable.lower()
_py3_include_path = '-I"' + os.path.join(
os.path.dirname(sys.executable),
"include"
) + '"'
candidate = [os.path.dirname(sys.executable)] + sys.path
for p in candidate:
include_path = os.path.join(p, "include")
if os.path.exists(include_path):
break
else:
raise RuntimeError("Python include path not found. please report this bug to us.")
_py3_include_path = '-I"' + include_path + '"'
else:
_py3_include_path = run_cmd(get_py3_config_path()+" --includes")