Skip to content

Commit

Permalink
Add python support for deployment. (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
smaEti authored Nov 17, 2024
1 parent b227d3a commit 67ad1bc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Additionally, you can also retry the build with the debug flag:

async __detectPlatformVersion(config: any, body: any) {
if (body.platformConfig.pythonVersion) {
// django and flask
// django, flask, python
this.logKeyValue('Python version', body.platformConfig.pythonVersion);
return body;
}
Expand All @@ -594,6 +594,7 @@ Additionally, you can also retry the build with the debug flag:
switch (config.platform) {
case 'django':
case 'flask':
case 'python':
platformVersion = await getPlatformVersion(
config.platform,
config.path,
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const AVAILABLE_PLATFORMS = [
'node',
'laravel',
'php',
'python',
'django',
'flask',
'dotnet',
Expand Down
1 change: 1 addition & 0 deletions src/services/get-platform-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async function getPlatformVersion(
switch (platform) {
case 'django':
case 'flask':
case 'python':
pureVersion = getPythonVersion(projectPath, debug);
break;
case 'php':
Expand Down
12 changes: 12 additions & 0 deletions src/utils/detect-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import addNullBetweenChars from './add-null-between-chars.js';

export default function detectPlatform(projectPath: string) {
const pipfilePath = path.join(projectPath, 'Pipfile');
const pyprojectFilePath = path.join(projectPath, 'pyproject.toml');
const poetryFilePath = path.join(projectPath, 'poetry');
const indexPHPFilePath = path.join(projectPath, 'index.php');
const packageJsonFilePath = path.join(projectPath, 'package.json');
const composeJsonFilePath = path.join(projectPath, 'composer.json');
Expand All @@ -20,6 +22,8 @@ export default function detectPlatform(projectPath: string) {
});

const hasPipfilePathFile = existsSync(pipfilePath);
const hasPyprojectPathFile = existsSync(pyprojectFilePath);
const hasPoetryPathFile = existsSync(poetryFilePath);
const hasIndexPHPFile = existsSync(indexPHPFilePath);
const hasPackageFile = existsSync(packageJsonFilePath);
const hasComposerJsonFile = existsSync(composeJsonFilePath);
Expand Down Expand Up @@ -69,6 +73,10 @@ Please specify your platform with --platform=laravel or docker.`);
return 'php';
}

if (hasPyprojectPathFile || hasPoetryPathFile) {
return 'python';
}

if (hasRequirementsTxtFile) {
const requirementsTxt = readFileSync(requirementsTxtFilePath);

Expand All @@ -89,6 +97,8 @@ Please specify your platform with --platform=laravel or docker.`);
) {
return 'flask';
}

return 'python';
}

if (hasPipfilePathFile) {
Expand All @@ -101,6 +111,8 @@ Please specify your platform with --platform=laravel or docker.`);
if (pipfile.includes('Flask') || pipfile.includes('flask')) {
return 'flask';
}

return 'python';
}

if (hasPackageFile && hasDockerFile) {
Expand Down
1 change: 1 addition & 0 deletions src/utils/get-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface IPorts {
export function getPort(platform: string): number {
const ports: IPorts = {
static: 80,
python: 80,
react: 80,
vue: 80,
angular: 80,
Expand Down

0 comments on commit 67ad1bc

Please sign in to comment.