5
5
6
6
def get_version ():
7
7
# Read version from CHANGELOG.md
8
- with open ('CHANGELOG.md' , 'r' , encoding = 'utf-8' ) as f :
9
- first_line = f .readline ().strip ()
10
- match = re .search (r'# \[(\d+\.\d+\.\d+)\]' , first_line )
11
- if match :
12
- version = match .group (1 )
13
-
14
- # Update version in __init__.py
15
- init_path = os .path .join ('simpletool' , '__init__.py' )
16
- with open (init_path , 'r' , encoding = 'utf-8' ) as init_file :
17
- init_content = init_file .read ()
18
-
19
- # Replace version in the header
20
- updated_init_content = re .sub (
21
- r'(version:)\s*' ,
22
- r'\1 ' + version ,
23
- init_content
24
- )
25
-
26
- with open (init_path , 'w' , encoding = 'utf-8' ) as init_file :
27
- init_file .write (updated_init_content )
28
-
29
- return version
30
- return '0.0.0' # fallback version if not found
8
+ try :
9
+ with open ('CHANGELOG.md' , 'r' , encoding = 'utf-8' ) as f :
10
+ for line in f :
11
+ line = line .strip ()
12
+ match = re .search (r'# \[(\d+\.\d+\.\d+)\]' , line )
13
+ if match :
14
+ version = match .group (1 )
15
+
16
+ # Update version in __init__.py
17
+ init_path = os .path .join ('simpletool' , '__init__.py' )
18
+ with open (init_path , 'r' , encoding = 'utf-8' ) as init_file :
19
+ init_content = init_file .read ()
20
+
21
+ # Replace version in the header
22
+ updated_init_content = re .sub (
23
+ r'(version:)\s*' ,
24
+ r'\1 ' + version ,
25
+ init_content
26
+ )
27
+
28
+ with open (init_path , 'w' , encoding = 'utf-8' ) as init_file :
29
+ init_file .write (updated_init_content )
30
+
31
+ return version
32
+ return '0.0.0' # fallback version if not found
33
+ except FileNotFoundError :
34
+ print ("CHANGELOG.md not found!" )
35
+ return '0.0.0'
31
36
32
37
33
38
setup (name = 'simpletool' ,
@@ -42,7 +47,7 @@ def get_version():
42
47
long_description = open ('README.md' ).read (),
43
48
long_description_content_type = 'text/markdown' ,
44
49
package_data = {
45
- 'simpletool' : ['CHANGELOG.md' , 'README.md' , ' LICENSE' ],
50
+ 'simpletool' : ['CHANGELOG.md' , 'LICENSE' ],
46
51
},
47
52
include_package_data = True ,
48
53
classifiers = [
0 commit comments