Skip to content

Commit 79c078f

Browse files
committed
always use "python" as the path in the layer. this works for python2.7, python3.6 and python3.7
1 parent 0cb238d commit 79c078f

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

lib/layer.js

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,17 @@ const { writeZip, addTree } = require('./zipTree');
66

77
BbPromise.promisifyAll(fse);
88

9-
/**
10-
* Get the paths for the compatible runtimes of the layer
11-
* @param {string[]} list of runtime paths
12-
*/
13-
function getRunTimeBuildPaths() {
14-
const runtimepaths = {
15-
'python2.7': 'python',
16-
'python3.6': path.join('python', 'lib', 'python3.6', 'site-packages'),
17-
'python3.7': path.join('python', 'lib', 'python3.7', 'site-packages')
18-
};
19-
20-
let runtimes = [];
21-
22-
// Defer to Layer config first
23-
if (this.options.layer.compatibleRuntimes) {
24-
runtimes = this.options.layer.compatibleRuntimes;
25-
// If none provided, assume the provider runtime
26-
} else if (this.serverless.service.provider.runtime) {
27-
runtimes = [this.serverless.service.provider.runtime];
28-
// If still no runtime found, just assume latest python
29-
} else {
30-
runtimes = ['python3.7'];
31-
}
32-
33-
return BbPromise.resolve(runtimes.map(runtime => runtimepaths[runtime]));
34-
}
35-
369
/**
3710
* Zip up requirements to be used as layer package.
38-
* @param {string[]} list of paths where the requirements should be put in the layer
3911
* @return {Promise} the JSZip object constructed.
4012
*/
41-
function zipRequirements(runtimepaths) {
13+
function zipRequirements() {
4214
const rootZip = new JSZip();
4315
const src = path.join('.serverless', 'requirements');
16+
const runtimepath = 'python';
4417

45-
return BbPromise.each(runtimepaths, runtimepath =>
46-
addTree(rootZip.folder(runtimepath), src)
47-
).then(() =>
48-
writeZip(rootZip, path.join('.serverless', 'pythonRequirementsLayer.zip'))
18+
return addTree(rootZip.folder(runtimepath), src).then(() =>
19+
writeZip(rootZip, path.join('.serverless', 'pythonRequirements.zip'))
4920
);
5021
}
5122

@@ -80,7 +51,6 @@ function layerRequirements() {
8051
this.serverless.cli.log('Packaging Python Requirements Lambda Layer...');
8152

8253
return BbPromise.bind(this)
83-
.then(getRunTimeBuildPaths)
8454
.then(zipRequirements)
8555
.then(createLayers);
8656
}

0 commit comments

Comments
 (0)