Initial commit
Browse files- preinstall.py +21 -0
- pyproject.toml +8 -0
preinstall.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
import sys
|
3 |
+
|
4 |
+
def clean_package(package_name):
|
5 |
+
"""Force uninstalls a package to ensure a clean state."""
|
6 |
+
print(f"Attempting to forcefully uninstall {package_name}...")
|
7 |
+
# Use -y to automatically confirm and run command
|
8 |
+
result = subprocess.run(
|
9 |
+
[sys.executable, "-m", "pip", "uninstall", "-y", package_name],
|
10 |
+
capture_output=True,
|
11 |
+
text=True
|
12 |
+
)
|
13 |
+
if result.returncode == 0:
|
14 |
+
print(f"Successfully uninstalled {package_name}.")
|
15 |
+
else:
|
16 |
+
# It's okay if it fails, it might just not be installed.
|
17 |
+
print(f"{package_name} not found or uninstall failed, continuing.")
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
clean_package("gradio")
|
21 |
+
clean_package("gradio_client")
|
pyproject.toml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pyproject.toml
|
2 |
+
[build-system]
|
3 |
+
requires = ["setuptools"]
|
4 |
+
build-backend = "setuptools.build_meta"
|
5 |
+
|
6 |
+
# Tell Hugging Face Spaces to run our script before installing dependencies
|
7 |
+
[tool.huggingface]
|
8 |
+
preinstall = "preinstall.py"
|