Skip to content

Commit 9a40b7a

Browse files
committed
Detecting Python better
1 parent f5a3850 commit 9a40b7a

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,4 @@ jobs:
235235
236236
- name: Build and Test
237237
shell: bash
238-
run: cmake --build out --config $BUILD_TYPE --target run-test
238+
run: cmake --build out --config $BUILD_TYPE --target test-20python

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endif()
3030

3131
add_subdirectory(lib)
3232

33-
if(${Python3_Interpreter_FOUND} AND ${Python3_VERSION} VERSION_GREATER "3.8")
33+
if(${Python3_Interpreter_FOUND} AND ${Python3_VERSION} VERSION_GREATER_EQUAL "3.9")
3434

3535
file(GLOB UNICODE_DATA ${CMAKE_CURRENT_LIST_DIR}/unicode/data/*.txt)
3636
file(GLOB UNICODE_SCRIPTS ${CMAKE_CURRENT_LIST_DIR}/unicode/scripts/*.py)

test/test_main.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ JNIEnv * g_env;
7373

7474
#endif
7575

76+
#if defined(SYS_STRING_USE_PYTHON) && defined(PYPY_VERSION)
77+
78+
extern "C" {
79+
void rpython_startup_code(void);
80+
int pypy_setup_home(char *home, int verbose);
81+
}
82+
83+
#endif
84+
7685
int main(int argc, char** argv)
7786
{
7887
#if defined(__ANDROID__)
@@ -85,9 +94,16 @@ int main(int argc, char** argv)
8594
SetConsoleOutputCP(CP_UTF8);
8695
#endif
8796

88-
#if defined(SYS_STRING_USE_PYTHON) && !defined(PYPY_VERSION)
89-
Py_Initialize();
97+
#if defined(SYS_STRING_USE_PYTHON)
98+
#if !defined(PYPY_VERSION)
99+
Py_Initialize();
100+
#else
101+
rpython_startup_code();
102+
pypy_setup_home(nullptr, 1);
103+
#endif
90104
#endif
105+
106+
91107

92108
return doctest::Context(argc, argv).run();
93109
}

0 commit comments

Comments
 (0)