-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
71 lines (59 loc) Β· 2.27 KB
/
setup.py
File metadata and controls
71 lines (59 loc) Β· 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import subprocess
import sys
import os
from pathlib import Path
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
def run_kokoro_download():
"""Run the kokoro download bash script"""
script_path = Path(__file__).parent / "download_kokoro.sh"
if not script_path.exists():
print(f"β οΈ Warning: Download script not found at {script_path}")
return
print("π― Running Kokoro download script...")
try:
# Make script executable
subprocess.run(["chmod", "+x", str(script_path)], check=True)
# Run the script and show output in real-time
process = subprocess.Popen(
["/bin/bash", str(script_path)],
cwd=Path(__file__).parent,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
bufsize=1
)
# Print output in real-time
for line in process.stdout:
print(line.rstrip())
process.wait()
if process.returncode == 0:
print("β
Kokoro download script completed successfully!")
else:
print(f"β οΈ Warning: Download script failed with return code {process.returncode}")
except subprocess.CalledProcessError as e:
print(f"β οΈ Warning: Failed to run download script: {e}")
except Exception as e:
print(f"β οΈ Warning: Unexpected error: {e}")
class PostDevelopCommand(develop):
"""Post-installation for development mode (pip install -e .)"""
def run(self):
print("π§ Running develop command...")
develop.run(self)
print("π§ Development installation complete, running kokoro download...")
run_kokoro_download()
class PostInstallCommand(install):
"""Post-installation for installation mode"""
def run(self):
print("π§ Running install command...")
install.run(self)
print("π§ Installation complete, running kokoro download...")
run_kokoro_download()
# Use setup() to add custom commands while keeping pyproject.toml configuration
setup(
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
)