xenfra 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xenfra/dockerizer.py
CHANGED
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
|
|
3
4
|
def detect_framework():
|
|
4
5
|
"""
|
|
5
|
-
Scans
|
|
6
|
+
Scans common Python project structures to guess the framework and entrypoint.
|
|
6
7
|
Returns: (framework_name, default_port, start_command) or (None, None, None)
|
|
7
8
|
"""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
project_root = Path(os.getcwd())
|
|
10
|
+
|
|
11
|
+
candidate_files = []
|
|
12
|
+
|
|
13
|
+
# Check directly in project root
|
|
14
|
+
for name in ["main.py", "app.py"]:
|
|
15
|
+
if (project_root / name).is_file():
|
|
16
|
+
candidate_files.append(project_root / name)
|
|
17
|
+
|
|
18
|
+
# Check in src/*/ (standard package layout)
|
|
19
|
+
for src_dir in project_root.glob("src/*"):
|
|
20
|
+
if src_dir.is_dir():
|
|
21
|
+
for name in ["main.py", "app.py"]:
|
|
22
|
+
if (src_dir / name).is_file():
|
|
23
|
+
candidate_files.append(src_dir / name)
|
|
24
|
+
|
|
25
|
+
for file_path in candidate_files:
|
|
26
|
+
with open(file_path, "r") as f:
|
|
11
27
|
content = f.read()
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
|
|
29
|
+
module_name = str(file_path.relative_to(project_root)).replace(os.sep, '.')[:-3]
|
|
30
|
+
# If path is like src/testdeploy/main.py, module_name becomes src.testdeploy.main
|
|
31
|
+
# For uvicorn/gunicorn, we usually want package.module (e.g., testdeploy.main)
|
|
32
|
+
if module_name.startswith("src."):
|
|
33
|
+
# Strip the "src." prefix
|
|
34
|
+
module_name = module_name[4:]
|
|
14
35
|
|
|
15
|
-
# 2. Flask Scan
|
|
16
|
-
if os.path.exists("app.py"):
|
|
17
|
-
with open("app.py", "r") as f:
|
|
18
|
-
content = f.read()
|
|
19
|
-
if "Flask" in content:
|
|
20
|
-
return "flask", 5000, "gunicorn app:app -b 0.0.0.0:5000"
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
if "FastAPI" in content:
|
|
38
|
+
return "fastapi", 8000, f"uvicorn {module_name}:app --host 0.0.0.0 --port 8000"
|
|
39
|
+
|
|
40
|
+
if "Flask" in content:
|
|
41
|
+
return "flask", 5000, f"gunicorn {module_name}:app -b 0.0.0.0:5000"
|
|
42
|
+
|
|
23
43
|
return None, None, None
|
|
24
44
|
|
|
25
45
|
def generate_deployment_assets(context):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
xenfra/__init__.py,sha256=ja0-Vc9T61EXZnPeX84Fi-UOjoGAWu5r90_1t-0WjVw,46
|
|
2
2
|
xenfra/cli.py,sha256=EXhzv5Zd5zNuON-X2mp00SE956_x0stzNUAN4X0tg7w,5840
|
|
3
|
-
xenfra/dockerizer.py,sha256=
|
|
3
|
+
xenfra/dockerizer.py,sha256=BmL13mYuja9Yst2YQlbxjYO5ZQ125L7LyfG_7pvGn-s,4052
|
|
4
4
|
xenfra/engine.py,sha256=A7Ov7_ub-24kfLjkuFZdwzu-AgIbTUpPCvx0t35d_e4,10636
|
|
5
5
|
xenfra/recipes.py,sha256=rf6dqrbc9P-LPMDQMt2iL100kVMhbWJRgfGYKJ5gqBQ,3780
|
|
6
6
|
xenfra/utils.py,sha256=aGXjJm-pwVCHuCn5UBdrxRcYvM8aJwHQ1kihl7gcxiM,2387
|
|
7
|
-
xenfra-0.1.
|
|
8
|
-
xenfra-0.1.
|
|
9
|
-
xenfra-0.1.
|
|
10
|
-
xenfra-0.1.
|
|
7
|
+
xenfra-0.1.1.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
|
|
8
|
+
xenfra-0.1.1.dist-info/entry_points.txt,sha256=pLGDlV0SH2hWunZJcEY7UkLLleMExFBaxgxRKYhU9mw,44
|
|
9
|
+
xenfra-0.1.1.dist-info/METADATA,sha256=TWb1BjRwqIFZLD8jprpamgIm180A-aIIvG_GbuRPx84,4222
|
|
10
|
+
xenfra-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|