Skip to content

Commit 9565783

Browse files
committed
Ensure __init__.py on all levels
1 parent 33c66e7 commit 9565783

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

js/scripts/generate-wrappers.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,18 @@ function createPythonWrapper(modulePath, className) {
921921

922922
function createPythonModuleInitFile(modulePath) {
923923

924-
const dirname = path.dirname(modulePath);
925-
const pyInitFilePath = path.resolve(pySrcDir, dirname, '__init__.py');
926-
return fse.ensureFile(pyInitFilePath);
924+
let dirname = path.dirname(path.resolve(pySrcDir, modulePath));
925+
let pyInitFilePath;
926+
const promises = [];
927+
while (dirname !== pySrcDir) {
928+
pyInitFilePath = path.join(dirname, '__init__.py');
929+
promises.push(fse.ensureFile(pyInitFilePath));
930+
if (dirname === path.dirname(dirname)) {
931+
throw new Error(`${dirname}, ${path.dirname(dirname)}`);
932+
}
933+
dirname = path.dirname(dirname);
934+
}
935+
return Promise.all(promises);
927936
}
928937

929938

0 commit comments

Comments
 (0)