Skip to content

Commit 67ad1bc

Browse files
authored
Add python support for deployment. (#196)
1 parent b227d3a commit 67ad1bc

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

src/commands/deploy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Additionally, you can also retry the build with the debug flag:
570570

571571
async __detectPlatformVersion(config: any, body: any) {
572572
if (body.platformConfig.pythonVersion) {
573-
// django and flask
573+
// django, flask, python
574574
this.logKeyValue('Python version', body.platformConfig.pythonVersion);
575575
return body;
576576
}
@@ -594,6 +594,7 @@ Additionally, you can also retry the build with the debug flag:
594594
switch (config.platform) {
595595
case 'django':
596596
case 'flask':
597+
case 'python':
597598
platformVersion = await getPlatformVersion(
598599
config.platform,
599600
config.path,

src/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const AVAILABLE_PLATFORMS = [
2828
'node',
2929
'laravel',
3030
'php',
31+
'python',
3132
'django',
3233
'flask',
3334
'dotnet',

src/services/get-platform-version.ts

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ async function getPlatformVersion(
4949
switch (platform) {
5050
case 'django':
5151
case 'flask':
52+
case 'python':
5253
pureVersion = getPythonVersion(projectPath, debug);
5354
break;
5455
case 'php':

src/utils/detect-platform.ts

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import addNullBetweenChars from './add-null-between-chars.js';
88

99
export default function detectPlatform(projectPath: string) {
1010
const pipfilePath = path.join(projectPath, 'Pipfile');
11+
const pyprojectFilePath = path.join(projectPath, 'pyproject.toml');
12+
const poetryFilePath = path.join(projectPath, 'poetry');
1113
const indexPHPFilePath = path.join(projectPath, 'index.php');
1214
const packageJsonFilePath = path.join(projectPath, 'package.json');
1315
const composeJsonFilePath = path.join(projectPath, 'composer.json');
@@ -20,6 +22,8 @@ export default function detectPlatform(projectPath: string) {
2022
});
2123

2224
const hasPipfilePathFile = existsSync(pipfilePath);
25+
const hasPyprojectPathFile = existsSync(pyprojectFilePath);
26+
const hasPoetryPathFile = existsSync(poetryFilePath);
2327
const hasIndexPHPFile = existsSync(indexPHPFilePath);
2428
const hasPackageFile = existsSync(packageJsonFilePath);
2529
const hasComposerJsonFile = existsSync(composeJsonFilePath);
@@ -69,6 +73,10 @@ Please specify your platform with --platform=laravel or docker.`);
6973
return 'php';
7074
}
7175

76+
if (hasPyprojectPathFile || hasPoetryPathFile) {
77+
return 'python';
78+
}
79+
7280
if (hasRequirementsTxtFile) {
7381
const requirementsTxt = readFileSync(requirementsTxtFilePath);
7482

@@ -89,6 +97,8 @@ Please specify your platform with --platform=laravel or docker.`);
8997
) {
9098
return 'flask';
9199
}
100+
101+
return 'python';
92102
}
93103

94104
if (hasPipfilePathFile) {
@@ -101,6 +111,8 @@ Please specify your platform with --platform=laravel or docker.`);
101111
if (pipfile.includes('Flask') || pipfile.includes('flask')) {
102112
return 'flask';
103113
}
114+
115+
return 'python';
104116
}
105117

106118
if (hasPackageFile && hasDockerFile) {

src/utils/get-port.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface IPorts {
55
export function getPort(platform: string): number {
66
const ports: IPorts = {
77
static: 80,
8+
python: 80,
89
react: 80,
910
vue: 80,
1011
angular: 80,

0 commit comments

Comments
 (0)