Spaces:
Running
on
Zero
Running
on
Zero
Commit
Β·
520ee21
1
Parent(s):
599fb2e
Update requirements_app.py
Browse files- app/requirements_app.py +30 -17
app/requirements_app.py
CHANGED
@@ -5,35 +5,48 @@ Description: Project requirements for the Gradio app.
|
|
5 |
License: MIT License
|
6 |
"""
|
7 |
|
|
|
|
|
8 |
import polars as pl
|
9 |
|
10 |
# Importing necessary components for the Gradio app
|
11 |
from app.config import config_data
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
def read_requirements(file_path="requirements.txt"):
|
15 |
with open(file_path, "r") as file:
|
16 |
lines = file.readlines()
|
17 |
|
18 |
data = []
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
{
|
32 |
-
config_data.Requirements_LIBRARY: library,
|
33 |
-
config_data.Requirements_RECOMMENDED_VERSION: recommended_version,
|
34 |
-
config_data.Requirements_CURRENT_VERSION: pypi(library),
|
35 |
-
}
|
36 |
-
)
|
37 |
|
38 |
df = pl.DataFrame(data)
|
39 |
|
|
|
5 |
License: MIT License
|
6 |
"""
|
7 |
|
8 |
+
import base64
|
9 |
+
import requests
|
10 |
import polars as pl
|
11 |
|
12 |
# Importing necessary components for the Gradio app
|
13 |
from app.config import config_data
|
14 |
|
15 |
|
16 |
+
def encode_image_to_base64(image_data: str) -> str:
|
17 |
+
return base64.b64encode(image_data).decode("utf-8")
|
18 |
+
|
19 |
+
|
20 |
+
def fetch_pypi_badge_base64(package_name: str) -> str:
|
21 |
+
url = f"https://img.shields.io/pypi/v/{package_name}"
|
22 |
+
|
23 |
+
response = requests.get(url)
|
24 |
+
response.raise_for_status()
|
25 |
+
base64_image = encode_image_to_base64(response.content)
|
26 |
+
|
27 |
+
return (
|
28 |
+
f"<a href='https://pypi.org/project/{package_name}' target='_blank'>"
|
29 |
+
f"<img src='data:image/svg+xml;base64,{base64_image}' alt='PyPI' /></a>"
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
def read_requirements(file_path="requirements.txt"):
|
34 |
with open(file_path, "r") as file:
|
35 |
lines = file.readlines()
|
36 |
|
37 |
data = []
|
38 |
|
39 |
+
data = [
|
40 |
+
{
|
41 |
+
config_data.Requirements_LIBRARY: split_line[0],
|
42 |
+
config_data.Requirements_RECOMMENDED_VERSION: split_line[1],
|
43 |
+
config_data.Requirements_CURRENT_VERSION: fetch_pypi_badge_base64(
|
44 |
+
split_line[0]
|
45 |
+
),
|
46 |
+
}
|
47 |
+
for line in lines
|
48 |
+
if (split_line := line.strip().split("==")) and len(split_line) == 2
|
49 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
df = pl.DataFrame(data)
|
52 |
|