Skip to content

Commit bc5f60f

Browse files
committed
检测到3.14就用3.14,否则不指定版本
1 parent 7c18c0c commit bc5f60f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

unity/cli/make.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ function tryGetPythonFromPath() {
6262
return null;
6363
}
6464

65+
function getPythonVersion() {
66+
try {
67+
const out = execFileSync('python', ['-c', 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")'], { encoding: 'utf8' }).trim();
68+
return out;
69+
} catch {
70+
return null;
71+
}
72+
}
73+
6574
const platformCompileConfig = {
6675
'android': {
6776
'armv7': {
@@ -434,6 +443,10 @@ async function runPuertsMake(cwd, options) {
434443
if (pyInfo && pyInfo.exe) {
435444
CmakeDArgs += ` -DPython3_EXECUTABLE="${pyInfo.exe}"`;
436445
}
446+
const pyVer = getPythonVersion();
447+
if (pyVer) {
448+
CmakeDArgs += ` -DPython3_VERSION=${pyVer}`;
449+
}
437450
}
438451

439452
var outputFile = BuildConfig.hook(

unity/native/papi-python/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ if(ANDROID)
5959
message(STATUS "Python library: ${Python3_LIBRARIES}")
6060
else()
6161
# For other platforms, use find_package
62-
find_package(Python3 3.14 COMPONENTS Interpreter Development REQUIRED)
62+
if("${Python3_VERSION}" MATCHES "3.14")
63+
message(STATUS "Python VERSION == 3.14")
64+
find_package(Python3 3.14 COMPONENTS Interpreter Development REQUIRED)
65+
else ()
66+
message(STATUS "Python VERSION != 3.14")
67+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
68+
endif()
6369
endif()
6470

6571
include_directories(

0 commit comments

Comments
 (0)