File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
packages/build/src/extensions Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ export type PythonOptions = {
2020 pythonBinaryPath ?: string ;
2121} ;
2222
23+ const splitAndCleanComments = ( str : string ) =>
24+ str
25+ . split ( "\n" )
26+ . map ( ( line ) => line . trim ( ) )
27+ . filter ( ( line ) => line && ! line . startsWith ( "#" ) ) ;
28+
2329export function pythonExtension ( options : PythonOptions = { } ) : BuildExtension {
2430 return new PythonExtension ( options ) ;
2531}
@@ -34,9 +40,9 @@ class PythonExtension implements BuildExtension {
3440 ) ;
3541
3642 if ( this . options . requirementsFile ) {
37- this . options . requirements = fs
38- . readFileSync ( this . options . requirementsFile , "utf-8" )
39- . split ( "\n" ) ;
43+ this . options . requirements = splitAndCleanComments (
44+ fs . readFileSync ( this . options . requirementsFile , "utf-8" )
45+ ) ;
4046 }
4147 }
4248
@@ -59,7 +65,7 @@ class PythonExtension implements BuildExtension {
5965 } ,
6066 } ,
6167 image : {
62- instructions : `
68+ instructions : splitAndCleanComments ( `
6369 # Install Python
6470 RUN apt-get update && apt-get install -y --no-install-recommends \
6571 python3 python3-pip python3-venv && \
@@ -74,7 +80,7 @@ class PythonExtension implements BuildExtension {
7480
7581 # Install dependenciess
7682 RUN pip install --no-cache-dir -r requirements.txt
77- ` . split ( "\n" ) ,
83+ ` ) ,
7884 } ,
7985 deploy : {
8086 env : {
You can’t perform that action at this time.
0 commit comments