Skip to content

Commit 832b7d6

Browse files
committed
Better mixed runtime & function deploy handling
fixes #161 and fixes #179
1 parent 94e9894 commit 832b7d6

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

index.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,28 @@ class ServerlessPythonRequirements {
108108
}
109109
};
110110

111-
const before = () =>
112-
BbPromise.bind(this)
111+
const before = () => {
112+
if (arguments[1].functionObj && arguments[1].functionObj.runtime && !arguments[1].functionObj.runtime.startsWith('python'))
113+
return;
114+
return BbPromise.bind(this)
113115
.then(pipfileToRequirements)
114116
.then(addVendorHelper)
115117
.then(installAllRequirements)
116118
.then(packRequirements);
119+
}
117120

118-
const after = () =>
119-
BbPromise.bind(this)
121+
const after = wat => {
122+
if (arguments[1].functionObj && arguments[1].functionObj.runtime && !arguments[1].functionObj.runtime.startsWith('python'))
123+
return;
124+
return BbPromise.bind(this)
120125
.then(removeVendorHelper)
121-
.then(injectAllRequirements);
126+
.then(() =>
127+
injectAllRequirements.bind(this)(
128+
arguments[1].functionObj &&
129+
arguments[1].functionObj.package.artifact
130+
)
131+
);
132+
};
122133

123134
const invalidateCaches = () => {
124135
if (this.options.invalidateCaches) {

lib/inject.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ function moveModuleUp(source, target, module) {
7272
* Inject requirements into packaged application.
7373
* @return {Promise} the combined promise for requirements injection.
7474
*/
75-
function injectAllRequirements() {
75+
function injectAllRequirements(artifact) {
76+
this.serverless.cli.log(artifact);
7677
this.serverless.cli.log('Injecting required Python packages to package...');
7778

7879
if (this.options.zip) {
@@ -114,7 +115,7 @@ function injectAllRequirements() {
114115
} else {
115116
return injectRequirements(
116117
path.join('.serverless', 'requirements'),
117-
this.serverless.service.package.artifact,
118+
artifact || this.serverless.service.package.artifact,
118119
this.options
119120
);
120121
}

tests/base/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-4.0.0.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-4.0.2.tgz"
1313
}
1414
}

0 commit comments

Comments
 (0)