Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit afb73a1

Browse files
committed
fix-version
1 parent f257173 commit afb73a1

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

setup.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,34 @@
55

66
def get_version():
77
# 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'
3136

3237

3338
setup(name='simpletool',
@@ -42,7 +47,7 @@ def get_version():
4247
long_description=open('README.md').read(),
4348
long_description_content_type='text/markdown',
4449
package_data={
45-
'simpletool': ['CHANGELOG.md', 'README.md', 'LICENSE'],
50+
'simpletool': ['CHANGELOG.md', 'LICENSE'],
4651
},
4752
include_package_data=True,
4853
classifiers=[

simpletool/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
name: SimpleTools
33
author: Artur Zdolinski
4-
version:
4+
version: 0.0.0
55
"""
66
import asyncio
77
import os

0 commit comments

Comments
 (0)