Skip to content

Commit c64c04e

Browse files
committed
feat: Support Scaleway provider
1 parent 012b55f commit c64c04e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class ServerlessPythonRequirements {
6363
this.serverless.service.custom.pythonRequirements) ||
6464
{}
6565
);
66+
if (/python3[0-9]+/.test(options.pythonBin)) {
67+
// "google" and "scaleway" providers' runtimes uses python3XX
68+
options.pythonBin = options.pythonBin.replace(/3([0-9]+)/, '3.$1');
69+
}
6670
if (options.dockerizePip === 'non-linux') {
6771
options.dockerizePip = process.platform !== 'linux';
6872
}

lib/inject.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ BbPromise.promisifyAll(fse);
1313
* Inject requirements into packaged application.
1414
* @param {string} requirementsPath requirements folder path
1515
* @param {string} packagePath target package path
16+
* @param {string} injectionRelativePath installation directory in target package
1617
* @param {Object} options our options object
1718
* @return {Promise} the JSZip object constructed.
1819
*/
19-
function injectRequirements(requirementsPath, packagePath, options) {
20+
function injectRequirements(
21+
requirementsPath,
22+
packagePath,
23+
injectionRelativePath,
24+
options
25+
) {
2026
const noDeploy = new Set(options.noDeploy || []);
2127

2228
return fse
@@ -29,7 +35,13 @@ function injectRequirements(requirementsPath, packagePath, options) {
2935
dot: true,
3036
})
3137
)
32-
.map((file) => [file, path.relative(requirementsPath, file)])
38+
.map((file) => [
39+
file,
40+
path.join(
41+
injectionRelativePath,
42+
path.relative(requirementsPath, file)
43+
),
44+
])
3345
.filter(
3446
([file, relativeFile]) =>
3547
!file.endsWith('/') &&
@@ -101,6 +113,11 @@ async function injectAllRequirements(funcArtifact) {
101113
this.serverless.cli.log('Injecting required Python packages to package...');
102114
}
103115

116+
let injectionRelativePath = '.';
117+
if (this.serverless.service.provider.name == 'scaleway') {
118+
injectionRelativePath = 'package';
119+
}
120+
104121
try {
105122
if (this.serverless.service.package.individually) {
106123
await BbPromise.resolve(this.targetFuncs)
@@ -138,13 +155,15 @@ async function injectAllRequirements(funcArtifact) {
138155
: injectRequirements(
139156
path.join('.serverless', func.module, 'requirements'),
140157
func.package.artifact,
158+
injectionRelativePath,
141159
this.options
142160
);
143161
});
144162
} else if (!this.options.zip) {
145163
await injectRequirements(
146164
path.join('.serverless', 'requirements'),
147165
this.serverless.service.package.artifact || funcArtifact,
166+
injectionRelativePath,
148167
this.options
149168
);
150169
}

0 commit comments

Comments
 (0)