llpyg: prompt import mod fail; py: fix typo

This commit is contained in:
xushiwei
2024-05-14 22:33:36 +08:00
parent f882221db3
commit e9570f2400
6 changed files with 267 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
// example:
// llgoLoadPyModSyms(mod, "name1", &func1, "name2", &func2, NULL)
@@ -23,3 +24,30 @@ void llgoLoadPyModSyms(PyObject* mod, ...) {
}
va_end(ap);
}
/*
wchar_t* toWcs(const char* str) {
size_t len = mbstowcs(NULL, str, 0);
wchar_t* wstr = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
mbstowcs(wstr, str, len + 1);
return wstr;
}
char* toMbs(const wchar_t* str) {
size_t len = wcstombs(NULL, str, 0);
char* mstr = (char*)malloc(len + 1);
wcstombs(mstr, str, len + 1);
return mstr;
}
wchar_t *Py_GetPath();
void Py_SetPath(const wchar_t* path);
void Py_Initialize();
void llgoPyInitialize() {
setenv("PYTHONPATH", "/opt/homebrew/lib/python3.12/site-packages", 1);
Py_Initialize();
printf("sys.path = %s\n", toMbs(Py_GetPath()));
}
*/