Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should append current script directory to sys.path for local importing #63

Open
manfeel opened this issue Aug 20, 2021 · 0 comments
Open

Comments

@manfeel
Copy link

manfeel commented Aug 20, 2021

modify py.cpp

bool pyInit(PLUG_INITSTRUCT* initStruct) {
    // ...
    // Add 'plugins' (current directory) to sys.path
    GetCurrentDirectoryW(_countof(dir), dir);
    if(dir[wcslen(dir) - 1] != L'\\')
        wcsncat_s(dir, L"\\", _TRUNCATE);
    wcsncat_s(dir, token_paste(L, module_name), _TRUNCATE);
    GetShortPathNameW(dir, dir, _countof(dir));
    _plugin_logputs(Utf16ToUtf8(dir).c_str());
    PyList_Insert(PySys_GetObject("path"), 0, PyString_FromString(Utf16ToUtf8(dir).c_str()));
    // Append current script directory to sys.path for local importing
    PyList_Append(PySys_GetObject("path"), PyString_FromString("."));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant