Skip to content

Commit 3a56c79

Browse files
committed
Honor env var PYTHONUSERBASE for C API location.
1 parent 3b15dc7 commit 3a56c79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,17 @@ private static String getScriptPath(Env env, String[] args) {
266266
}
267267

268268
private static String getCapiHome(Env env, PythonModule sys) {
269-
return String.join(env.getFileNameSeparator(), getCapiUserBase(env, sys), "lib", "capi");
269+
String pythonSubdir = "python" + PythonLanguage.MAJOR + "." + PythonLanguage.MINOR;
270+
return String.join(env.getFileNameSeparator(), getCapiUserBase(env, sys), "lib", pythonSubdir, "capi");
270271
}
271272

272273
// similar to 'sysconfig._getuserbase()'
273274
private static String getCapiUserBase(Env env, PythonModule sys) {
275+
String customUserBase = env.getEnvironment().get("PYTHONUSERBASE");
276+
if (customUserBase != null) {
277+
return customUserBase;
278+
}
279+
274280
Object osName = sys.getAttribute("platform");
275281
if (FRAMEWORK != PNone.NONE && PLATFORM_DARWIN.equals(osName)) {
276282
String _framework = FRAMEWORK.toString();

0 commit comments

Comments
 (0)