sterepando commited on
Commit
3ea5307
·
verified ·
1 Parent(s): 9e97862

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -110
app.py DELETED
@@ -1,110 +0,0 @@
1
- import gradio as gr
2
- import subprocess
3
- import os
4
- import shutil
5
- from pathlib import Path
6
-
7
- def build_pydantic_wheel():
8
- """Собирает pydantic-core wheel для Android ARM64"""
9
-
10
- output_dir = Path("/tmp/wheels")
11
- output_dir.mkdir(exist_ok=True)
12
-
13
- # Очищаем старые файлы
14
- for file in output_dir.glob("*"):
15
- file.unlink()
16
-
17
- try:
18
- # Используем cibuildwheel для сборки
19
- env = os.environ.copy()
20
- env["CIBW_BUILD"] = "cp311-*"
21
- env["CIBW_ARCHS"] = "aarch64"
22
- env["CIBW_BUILD_FRONTEND"] = "build"
23
-
24
- result = subprocess.run([
25
- "pip", "wheel",
26
- "pydantic-core",
27
- "--no-deps",
28
- "-w", str(output_dir),
29
- "--platform", "android_21_arm64_v8a",
30
- "--python-tag", "cp311",
31
- "--abi-tag", "cp311"
32
- ], capture_output=True, text=True, env=env)
33
-
34
- # Ищем созданный wheel
35
- wheels = list(output_dir.glob("*.whl"))
36
-
37
- if wheels:
38
- wheel_path = wheels[0]
39
- return str(wheel_path), f"✅ Успешно собрано: {wheel_path.name}\n\n{result.stdout}"
40
- else:
41
- # Пробуем альтернативный метод - скачивание исходников и сборка
42
- subprocess.run(["pip", "download", "pydantic-core", "--no-binary", ":all:", "-d", "/tmp/src"], check=True)
43
-
44
- src_dir = Path("/tmp/src")
45
- for tar_file in src_dir.glob("pydantic*.tar.gz"):
46
- subprocess.run(["tar", "-xzf", str(tar_file), "-C", "/tmp/src"], check=True)
47
-
48
- for build_dir in src_dir.glob("pydantic-core-*"):
49
- if build_dir.is_dir():
50
- os.chdir(build_dir)
51
- subprocess.run([
52
- "python", "setup.py", "bdist_wheel",
53
- "--plat-name", "android_21_arm64_v8a",
54
- "--python-tag", "cp311"
55
- ], check=True)
56
-
57
- dist_dir = build_dir / "dist"
58
- for wheel in dist_dir.glob("*.whl"):
59
- shutil.copy(wheel, output_dir)
60
- return str(output_dir / wheel.name), f"✅ Собрано: {wheel.name}"
61
-
62
- return None, f"❌ Не удалось найти wheel\n{result.stdout}\n{result.stderr}"
63
-
64
- except Exception as e:
65
- return None, f"❌ Ошибка сборки: {str(e)}"
66
-
67
- def download_wheel(file_path):
68
- """Возвращает путь для скачивания"""
69
- if file_path and os.path.exists(file_path):
70
- return file_path
71
- return None
72
-
73
- # Gradio интерфейс
74
- with gr.Blocks(theme=gr.themes.Soft(), title="Pydantic-core Builder") as demo:
75
- gr.Markdown("# 🚀 Pydantic-core Wheel Builder")
76
- gr.Markdown("Сборка pydantic-core для **Android ARM64 (cp311)**")
77
-
78
- with gr.Row():
79
- build_btn = gr.Button("⚡ Собрать Wheel", variant="primary", size="lg")
80
-
81
- with gr.Row():
82
- output_text = gr.Textbox(label="Вывод сборки", lines=10, max_lines=20)
83
-
84
- with gr.Row():
85
- download_file = gr.File(label="📦 Скачать .whl файл")
86
-
87
- def build_and_return(progress=gr.Progress()):
88
- progress(0, desc="Начинаем сборку...")
89
- file_path, message = build_pydantic_wheel()
90
- progress(1, desc="Готово!")
91
- return message, file_path
92
-
93
- build_btn.click(
94
- fn=build_and_return,
95
- outputs=[output_text, download_file]
96
- )
97
-
98
- gr.Markdown("""
99
- ---
100
- ### 📝 Инструкция:
101
- 1. Нажми кнопку "Собрать Wheel"
102
- 2. Дождись завершения сборки (~1-3 мин)
103
- 3. Скачай готовый .whl файл
104
-
105
- **Платформа:** android_21_arm64_v8a
106
- **Python:** 3.11 (cp311-cp311)
107
- """)
108
-
109
- if __name__ == "__main__":
110
- demo.launch(server_name="0.0.0.0", server_port=7860)