File size: 541 Bytes
dd64f21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pathlib
import pkg_resources
import re


package_name = "streamlit"

with pathlib.Path("requirements.txt").open() as requirements_txt:
    for requirement in pkg_resources.parse_requirements(requirements_txt):
        if requirement.name == package_name:
            version = requirement.specs[0][-1]
            break
print(version)


with open("README.md", "r") as f:
    contents = f.read()
    replaced = re.sub(r"sdk_version:.*", f"sdk_version: {version}", contents, 1)


with open("README.md", "w") as f:
    f.write(replaced)