Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
});
},
},
$trs: {},
};

</script>
Expand Down
27 changes: 26 additions & 1 deletion packages/kolibri-build/src/read_webpack_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ const temp = require('temp').track();

const webpack_json = path.resolve(path.dirname(__filename), './webpack_json.py');

const VENV_PYTHON = process.platform === 'win32' ? ['Scripts', 'python.exe'] : ['bin', 'python'];

// uv puts the project environment in `.venv` unless UV_PROJECT_ENVIRONMENT overrides it,
// and resolves a relative override against the project root.
const PROJECT_VENV = process.env.UV_PROJECT_ENVIRONMENT || '.venv';

// webpack_json.py has to import the plugin modules, so it needs the interpreter they are
// installed into. A bare `python` is the system interpreter whenever the build runs
// outside an activated shell — CI calling `make`, an editor task runner — and there the
// plugins are not importable at all.
function resolvePython() {
if (process.env.VIRTUAL_ENV) {
return path.join(process.env.VIRTUAL_ENV, ...VENV_PYTHON);
}
for (let dir = process.cwd(); ; dir = path.dirname(dir)) {
const candidate = path.join(path.resolve(dir, PROJECT_VENV), ...VENV_PYTHON);
if (fs.existsSync(candidate)) {
return candidate;
}
if (path.dirname(dir) === dir) {
return 'python';
}
}
}

function parseConfig(buildConfig, pythonData, configPath, index = null) {
// Set the bundleId by a concatenation of the Python module path
// And the specified bundle_id that should be unique within this plugin.
Expand Down Expand Up @@ -42,7 +67,7 @@ function readPythonPlugins({ pluginFile, plugins, pluginPath }) {
args.push('--plugin_path', pluginPath);
}
}
execFileSync('python', args);
execFileSync(resolvePython(), args);

const result = fs.readFileSync(webpack_json_tempfile);

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ exclude_lines = [
[tool.kolibri.i18n]
project = "kolibri"
locale_data_folder = "kolibri/locale"
ignore = "**/node_modules/**,**/static/**"
ignore = "**/node_modules/**,**/static/**,**/__tests__/**"
Loading