mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
aider: Added a script to check the latest version of the 'aider' package on PyPI and compare it with the current installed version.
# Aider chat conversation: USER: write a script that checks pypi to see if a newer version of aider is available ASSISTANT: To accomplish this, we will use the `requests` and `bs4` (BeautifulSoup) libraries in Python to scrape the PyPI website for the latest version of the `aider` package. We will add this script to the `aider/versioncheck.py` file. Here are the steps: 1. Import the necessary libraries. 2. Define a function that sends a GET request to the PyPI page for the `aider` package. 3. Parse the HTML response to find the latest version number. 4. Compare this version number with the current version of `aider` installed in the system. 5. Print a message indicating whether a newer version is available. Here is the code: ```python aider/versioncheck.py <<<<<<< ORIGINAL ======= import requests from bs4 import BeautifulSoup import pkg_resources def check_version(): response = requests.get('https://pypi.org/project/aider/') soup = BeautifulSoup(response.text, 'html.parser') latest_version = soup.find('h1', {'class': 'package-header__name'}).text.split()[-1] current_version = pkg_resources.get_distribution('aider').version if pkg_resources.parse_version(latest_version) > pkg_resources.parse_version(current_version): print(f"A newer version of 'aider' is available: {latest_version}") else: print("You are using the latest version of 'aider'.") if __name__ == "__main__": check_version() >>>>>>> UPDATED ``` Please note that this script assumes that `requests`, `bs4`, and `pkg_resources` are installed in your Python environment. If not, you can install them using pip: ```bash pip install requests beautifulsoup4 setuptools ```
This commit is contained in:
parent
7d9d163561
commit
51943b68e2
1 changed files with 17 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import pkg_resources
|
||||
|
||||
def check_version():
|
||||
response = requests.get('https://pypi.org/project/aider/')
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
latest_version = soup.find('h1', {'class': 'package-header__name'}).text.split()[-1]
|
||||
current_version = pkg_resources.get_distribution('aider').version
|
||||
|
||||
if pkg_resources.parse_version(latest_version) > pkg_resources.parse_version(current_version):
|
||||
print(f"A newer version of 'aider' is available: {latest_version}")
|
||||
else:
|
||||
print("You are using the latest version of 'aider'.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_version()
|
Loading…
Add table
Add a link
Reference in a new issue