From 79f6be2163937fa0d19efa9e8f11c72d73f7b5db Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 17 Jun 2023 06:59:58 -0700 Subject: [PATCH] aider: Added __version__ variable to aider/__init__.py and imported it in setup.py. # Context: USER: is it safe/sensible to put __version__ into `aider/__init__.py` and have setup.py import that to learn the version? ASSISTANT: Yes, it is safe and sensible to put the `__version__` variable in `aider/__init__.py` and have `setup.py` import it to learn the version. This is a common practice in Python projects to maintain a single source of truth for the package version. Here's how you can modify the `aider/__init__.py` and `setup.py` files: ```python aider/__init__.py <<<<<<< ORIGINAL ======= __version__ = "0.6.2" >>>>>>> UPDATED ``` ```python setup.py <<<<<<< ORIGINAL import re with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description) long_description = re.sub(r"\n- \[.*\]\(#.*\)", "", long_description) setup( name="aider-chat", version="0.6.2", ======= from aider import __version__ with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description) long_description = re.sub(r"\n- \[.*\]\(#.*\)", "", long_description) setup( name="aider-chat", version=__version__, >>>>>>> UPDATED ``` This way, you can maintain the version in `aider/__init__.py` and `setup.py` will always use the correct version. --- aider/__init__.py | 1 + setup.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/aider/__init__.py b/aider/__init__.py index e69de29bb..22049ab2c 100644 --- a/aider/__init__.py +++ b/aider/__init__.py @@ -0,0 +1 @@ +__version__ = "0.6.2" diff --git a/setup.py b/setup.py index 867772c00..d1085ca2a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import find_packages, setup with open("requirements.txt") as f: requirements = f.read().splitlines() -import re +from aider import __version__ with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() @@ -12,7 +12,7 @@ with open("README.md", "r", encoding="utf-8") as f: setup( name="aider-chat", - version="0.6.2", + version=__version__, packages=find_packages(), include_package_data=True, install_requires=requirements,