Eric Botti commited on
Commit
c309f22
1 Parent(s): 8f081cb

streamlit version from requirements

Browse files
Files changed (1) hide show
  1. scripts/update_readme.py +19 -7
scripts/update_readme.py CHANGED
@@ -1,23 +1,35 @@
1
- import os
 
 
 
 
 
 
 
 
 
 
 
2
 
 
3
  readme_path = "README.md"
4
 
5
- hf_space_metadata="""
6
  ---
7
  title: Chameleon
8
  emoji: 🦎
9
  colorFrom: green
10
  colorTo: yellow
11
  sdk: streamlit
12
- sdk_version: 1.31.1
13
  app_file: src/app.py
14
  pinned: true
15
  ---
16
  """
17
 
18
  # Open the README file
19
- with open(readme_path, 'r') as original:
20
- data = original.read()
21
  # Rewrite the README file, with metadata prepended
22
- with open(readme_path, 'w') as modified:
23
- modified.write(hf_space_metadata + data)
 
1
+ """
2
+ Script to update the README file with the metadata required by Hugging Face Spaces.
3
+ """
4
+
5
+ # Get Streamlit Version
6
+ requirements_path = "requirements.txt"
7
+
8
+ with open(requirements_path, 'r', encoding='utf-16') as requirements:
9
+ for line in requirements:
10
+ if line.strip().startswith("streamlit=="):
11
+ streamlit_version = line.strip().split('==')[1]
12
+ break
13
 
14
+ # Update README
15
  readme_path = "README.md"
16
 
17
+ hf_space_metadata = f"""
18
  ---
19
  title: Chameleon
20
  emoji: 🦎
21
  colorFrom: green
22
  colorTo: yellow
23
  sdk: streamlit
24
+ sdk_version: {streamlit_version}
25
  app_file: src/app.py
26
  pinned: true
27
  ---
28
  """
29
 
30
  # Open the README file
31
+ with open(readme_path, 'r') as original_readme:
32
+ data = original_readme.read()
33
  # Rewrite the README file, with metadata prepended
34
+ with open(readme_path, 'w', encoding="utf-16") as modified_readme:
35
+ modified_readme.write(hf_space_metadata + data)