Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/eleven-months-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/python": patch
---

Fixed the bug where you can only specify the requirements file as top level
2 changes: 1 addition & 1 deletion packages/python/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PythonExtension implements BuildExtension {
image: {
instructions: splitAndCleanComments(`
# Copy the requirements file
COPY ${this.options.requirementsFile} .
COPY ${this.options.requirementsFile} ${this.options.requirementsFile}
# Install dependencies
RUN pip install --no-cache-dir -r ${this.options.requirementsFile}
Comment on lines +124 to 126
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use JSON-array COPY and quote the pip path; normalize for Windows backslashes

Prevents failures when the requirements path contains spaces or backslashes and makes COPY unambiguous.

-            COPY ${this.options.requirementsFile} ${this.options.requirementsFile}
+            COPY ["${this.options.requirementsFile.replace(/\\\\/g, "/")}", "${this.options.requirementsFile.replace(/\\\\/g, "/")}"]
             # Install dependencies
-            RUN pip install --no-cache-dir -r ${this.options.requirementsFile}
+            RUN pip install --no-cache-dir -r "${this.options.requirementsFile.replace(/\\\\/g, "/")}"

If you prefer readability, precompute the normalized path once and reuse it:

// above, before context.addLayer(...)
const reqFile = this.options.requirementsFile!.replace(/\\/g, "/");

and then:

-            COPY ["${this.options.requirementsFile.replace(/\\\\/g, "/")}", "${this.options.requirementsFile.replace(/\\\\/g, "/")}"]
+            COPY ["${reqFile}", "${reqFile}"]
-            RUN pip install --no-cache-dir -r "${this.options.requirementsFile.replace(/\\\\/g, "/")}"
+            RUN pip install --no-cache-dir -r "${reqFile}"
🤖 Prompt for AI Agents
In packages/python/src/extension.ts around lines 124 to 126, the Dockerfile COPY
and RUN lines can break when requirementsFile contains spaces or Windows
backslashes; normalize the path (replace backslashes with "/") once into a
variable (e.g. reqFile) and then use the JSON-array form for COPY and quote the
pip path in RUN so the COPY is unambiguous and pip receives a quoted, normalized
path (i.e., use COPY ["<reqFile>","<reqFile>"] and RUN pip install
--no-cache-dir -r "<reqFile>").

`),
Expand Down