File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,30 @@ def extract_file_extension_from_url(url):
1515
1616
1717def get_version ():
18- package_path = Path (__file__ ).parent .parent / "pyproject.toml"
19- with open (package_path , "r" ) as f :
20- content = f .read ()
21-
22- for line in content .splitlines ():
23- if line .startswith ("version = " ):
24- return line .split ("=" )[1 ].strip ().strip ("\" '" )
25- return "unknown"
18+ try :
19+ import importlib .metadata
20+ return importlib .metadata .version ("musicai-sdk" )
21+ except (ImportError , importlib .metadata .PackageNotFoundError ):
22+ try :
23+ import os
24+ import musicai_sdk
25+
26+ package_dir = os .path .dirname (os .path .abspath (musicai_sdk .__file__ ))
27+
28+ pyproject_path = os .path .join (
29+ os .path .dirname (package_dir ), "pyproject.toml"
30+ )
31+
32+ if os .path .exists (pyproject_path ):
33+ with open (pyproject_path , "r" ) as f :
34+ for line in f :
35+ if line .strip ().startswith ("version" ):
36+ version = line .split ("=" )[1 ].strip ().strip ("\" '" )
37+ return version
38+ except Exception :
39+ pass
40+
41+ return "unknown"
2642
2743
2844def get_user_agent (environment = "SDK-Python" , version = None ):
Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " musicai-sdk"
3- version = " 1.0.1 "
3+ version = " 1.0.2 "
44description = " Python SDK for Music.AI"
55authors = [" Music.ai Support <support@music.ai>" ]
66license = " MIT"
You can’t perform that action at this time.
0 commit comments