Skip to content

Commit ea126a7

Browse files
committed
changes to requirements don’t invalidate the entire install layer
1 parent d45fd15 commit ea126a7

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

packages/build/src/extensions/python.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ class PythonExtension implements BuildExtension {
5858
context.logger.debug(`Adding ${this.name} to the build`);
5959

6060
context.addLayer({
61-
id: "python-extension",
62-
build: {
63-
env: {
64-
REQUIREMENTS_CONTENT: this.options.requirements?.join("\n") || "",
65-
},
66-
},
61+
id: "python-installation",
6762
image: {
6863
instructions: splitAndCleanComments(`
6964
# Install Python
@@ -74,7 +69,25 @@ class PythonExtension implements BuildExtension {
7469
# Set up Python environment
7570
RUN python3 -m venv /opt/venv
7671
ENV PATH="/opt/venv/bin:$PATH"
72+
`),
73+
},
74+
deploy: {
75+
env: {
76+
PYTHON_BIN_PATH: `/opt/venv/bin/python`,
77+
},
78+
override: true,
79+
},
80+
});
7781

82+
context.addLayer({
83+
id: "python-dependencies",
84+
build: {
85+
env: {
86+
REQUIREMENTS_CONTENT: this.options.requirements?.join("\n") || "",
87+
},
88+
},
89+
image: {
90+
instructions: splitAndCleanComments(`
7891
ARG REQUIREMENTS_CONTENT
7992
RUN echo "$REQUIREMENTS_CONTENT" > requirements.txt
8093
@@ -83,9 +96,6 @@ class PythonExtension implements BuildExtension {
8396
`),
8497
},
8598
deploy: {
86-
env: {
87-
PYTHON_BIN_PATH: `/opt/venv/bin/python`,
88-
},
8999
override: true,
90100
},
91101
});

0 commit comments

Comments
 (0)