Skip to content

Instantly share code, notes, and snippets.

@mehdisadeghi
Created August 16, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdisadeghi/7b17a8eb5d5db2ae8de722d469d4a174 to your computer and use it in GitHub Desktop.
Save mehdisadeghi/7b17a8eb5d5db2ae8de722d469d4a174 to your computer and use it in GitHub Desktop.
serverless-package-python-functions patch for pip upgrade and aws invoke local
121a122,124
> this.log('Upgrading pip inside the container.')
> this.runProcess('docker', ['exec', this.containerName, 'pip', 'install', '--upgrade', 'pip'])
> this.log('Pip upgrade finished.')
166a170,187
> loadEnvVars() {
> let pythonPath = ''
> if (this.globalIncludes) {
> this.log(`Adding global includes to the python path: ${this.globalIncludes}`)
> pythonPath += `:${this.globalIncludes}`
> }
>
> if (this.options.f) {
> pythonPath += `:${this.options.f}`
>
> if (this.serverless.service.functions[this.options.f].package.include) {
> this.serverless.service.functions[this.options.f].package.include.forEach(
> (item) => {pythonPath += `:${item}`})
> }
> }
> process.env['PYTHONPATH'] = pythonPath
> }
>
181c202,205
< .then(this.clean)
---
> .then(this.clean),
>
> 'invoke:local:loadEnvVars': () => BbPromise.bind(this)
> .then(this.fetchConfig).then(this.loadEnvVars),
@mehdisadeghi
Copy link
Author

mehdisadeghi commented Aug 16, 2018

Just patch your installation and you are good to go:

patch node_modules/serverless-package-python-functions/index.js sls.patch

Related Github issue: ubaniabalogun/serverless-package-python-functions#26

Edit: I have used the following commit to create the above patch:
ubaniabalogun/serverless-package-python-functions@917d4ce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment