Skip to content

Commit c21cde0

Browse files
committed
Implement version management with VERSION file and update package structure
1 parent e64eaac commit c21cde0

File tree

5 files changed

+45
-20
lines changed

5 files changed

+45
-20
lines changed

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include VERSION
2+
include README.md
3+
include requirements.txt
4+
include requirements-dev.txt
5+
recursive-include codebase_digest/prompt_library *.md

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.38

codebase_digest/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
from .app import main
1+
import os
2+
3+
def read_version():
4+
version_file = os.path.join(os.path.dirname(__file__), '..', 'VERSION')
5+
try:
6+
with open(version_file) as f:
7+
return f.read().strip()
8+
except FileNotFoundError:
9+
return "unknown"
10+
11+
__version__ = read_version()

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from setuptools import setup, find_packages
22
import os
33

4+
with open('VERSION') as f:
5+
version = f.read().strip()
6+
47
def read_requirements(filename='requirements.txt'):
58
"""Read the requirements from the given filename"""
69
current_dir = os.path.dirname(os.path.abspath(__file__))
@@ -15,7 +18,7 @@ def read_requirements(filename='requirements.txt'):
1518

1619
setup(
1720
name="codebase-digest",
18-
version='0.1.38',
21+
version=version,
1922
author="Kamil Stanuch",
2023
description="Consolidates and analyzes codebases for insights.",
2124
long_description=long_description,

update_package.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,35 @@ def upload_to_pypi(dist_files, max_attempts=3):
106106
return False
107107

108108
def update_version():
109+
with open('VERSION', 'r') as f:
110+
current_version = f.read().strip()
111+
112+
print(f"Current version: {current_version}")
113+
while True:
114+
new_version = input("Enter new version number (e.g., 0.1.7): ")
115+
if re.match(r'^\d+(\.\d+){0,2}(\.?[a-zA-Z0-9]+)?$', new_version):
116+
try:
117+
version.parse(new_version)
118+
break
119+
except version.InvalidVersion:
120+
print("Invalid version format. Please use a valid version number.")
121+
else:
122+
print("Invalid version format. Please use a valid version number.")
123+
124+
# Update VERSION file
125+
with open('VERSION', 'w') as f:
126+
f.write(new_version)
127+
128+
# Update setup.py
109129
with open('setup.py', 'r') as f:
110-
content = f.readlines()
130+
content = f.read()
111131

112-
for i, line in enumerate(content):
113-
if line.strip().startswith('version='):
114-
current_version = line.split('=')[1].strip().strip("'").strip('"')
115-
print(f"Current version: {current_version}")
116-
while True:
117-
new_version = input("Enter new version number (e.g., 0.1.7): ")
118-
if re.match(r'^\d+(\.\d+){0,2}(\.?[a-zA-Z0-9]+)?$', new_version):
119-
try:
120-
version.parse(new_version)
121-
break
122-
except version.InvalidVersion:
123-
print("Invalid version format. Please use a valid version number.")
124-
else:
125-
print("Invalid version format. Please use a valid version number.")
126-
content[i] = f" version='{new_version}',\n"
127-
break
132+
updated_content = re.sub(r"version=['\"][\d.]+['\"]", f"version='{new_version}'", content)
128133

129134
with open('setup.py', 'w') as f:
130-
f.writelines(content)
135+
f.write(updated_content)
131136

137+
print(f"Updated VERSION file and setup.py with new version: {new_version}")
132138
return new_version
133139

134140
def main():

0 commit comments

Comments
 (0)