diff --git a/Dockerfile b/Dockerfile index 53d7835..b87e023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,9 @@ FROM build-base AS labext-builder # Copy manifests first so dependency install is cacheable between source edits. WORKDIR /src/labextension COPY labextension/.yarnrc.yml labextension/package.json labextension/pyproject.toml labextension/tsconfig.json labextension/install.json ./ +# Yarn resolutions reference a local patch (license-webpack-plugin fix); it must +# exist before `jlpm install` resolves dependencies. +COPY labextension/.yarn ./.yarn RUN jlpm install COPY labextension/style ./style @@ -52,10 +55,13 @@ WORKDIR /app COPY --from=judge-builder /tmp/wheels /tmp/wheels COPY --from=labext-builder /tmp/wheels /tmp/wheels +# torch >=2 treats NumPy as optional; without it `import torch` prints a +# "Failed to initialize NumPy" warning and tensor<->numpy interop is disabled. RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir \ torch --index-url https://download.pytorch.org/whl/cpu && \ pip install --no-cache-dir \ + numpy \ /tmp/wheels/*.whl && \ rm -rf /tmp/wheels diff --git a/labextension/.yarn/patches/license-webpack-plugin-npm-4.0.2-1e0a964980.patch b/labextension/.yarn/patches/license-webpack-plugin-npm-4.0.2-1e0a964980.patch new file mode 100644 index 0000000..162460f --- /dev/null +++ b/labextension/.yarn/patches/license-webpack-plugin-npm-4.0.2-1e0a964980.patch @@ -0,0 +1,17 @@ +diff --git a/dist/WebpackInnerModuleIterator.js b/dist/WebpackInnerModuleIterator.js +index 282271e7411aa6221e408befb4ecfb259edc5896..b55935ad110758a1be09c614fbc1fdc4ed97133e 100644 +--- a/dist/WebpackInnerModuleIterator.js ++++ b/dist/WebpackInnerModuleIterator.js +@@ -58,7 +58,11 @@ var WebpackInnerModuleIterator = /** @class */ (function () { + return tokens[tokens.length - 1]; + } + if (filename.indexOf('provide module') === 0) { +- return filename.split('=')[1].trim(); ++ // Newer webpack emits self-provided Module Federation shares as ++ // "provide module (default) name@version|/path" (pipe separator, no '='), ++ // so split('=')[1] is undefined. Skip those instead of crashing on .trim(). ++ var providedFile = filename.split('=')[1]; ++ return providedFile == null ? null : providedFile.trim(); + } + if (filename.indexOf('consume-shared-module') === 0) { + var tokens = filename.split('|'); diff --git a/labextension/package.json b/labextension/package.json index ab01ab3..1b1fa1e 100644 --- a/labextension/package.json +++ b/labextension/package.json @@ -36,5 +36,8 @@ "jupyterlab": { "extension": true, "outputDir": "torchcode_labext/labextension" + }, + "resolutions": { + "license-webpack-plugin@^4.0.2": "patch:license-webpack-plugin@npm%3A4.0.2#./.yarn/patches/license-webpack-plugin-npm-4.0.2-1e0a964980.patch" } }