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

Commit 5efbc21

Browse files
authored
Merge pull request #208 from bancorprotocol/207-fix-current-version-requirementstxt-file
added version checker and requirements change
2 parents b354e4a + abf9d26 commit 5efbc21

File tree

4 files changed

+70
-10
lines changed

4 files changed

+70
-10
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from packaging import version as pkg_version
2+
from importlib.metadata import version
3+
4+
5+
class VersionRequirementError(Exception):
6+
"""
7+
A custom exception class for version requirement errors.
8+
9+
Args:
10+
installed_version (str): The installed version of web3.py.
11+
required_version (str): The required version of web3.py.
12+
13+
Raises:
14+
None
15+
"""
16+
17+
def __init__(self, installed_version, required_version):
18+
super().__init__(
19+
f""
20+
f"\n\n************** Version Requirement Error **************\n\n"
21+
f"Your current web3.py version is {installed_version}, which does not meet the requirement of ~= {required_version}.\n"
22+
f"Please upgrade your web3.py version to {required_version}.\n"
23+
f"We recommend using the latest requirements.txt file to install the latest versions of all "
24+
f"dependencies.\n\n"
25+
f"Run `pip install -r requirements.txt` from the project directory of the fastlane-bot repo.\n"
26+
f"\n\n************** Version Requirement Error **************\n\n"
27+
f""
28+
)
29+
30+
31+
def check_version_requirements():
32+
with open("requirements.txt", "r") as f:
33+
requirements = f.read().splitlines()
34+
35+
web3_version = [r for r in requirements if "web3" in r][0]
36+
required_version = web3_version.split("~=")[1]
37+
38+
# Get the installed version of web3
39+
installed_version = version("web3")
40+
41+
# Check the version and raise an exception if the requirement is not met
42+
if not pkg_version.parse(installed_version) <= pkg_version.parse("5.32.0"):
43+
raise VersionRequirementError(installed_version, required_version)

main.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
(c) Copyright Bprotocol foundation 2023.
66
Licensed under MIT
77
"""
8+
9+
from fastlane_bot.events.version_utils import check_version_requirements
10+
11+
check_version_requirements()
12+
813
import os
914
import time
10-
from glob import glob
1115
from typing import List
1216

1317
import click
1418
import pandas as pd
1519
from dotenv import load_dotenv
1620
from web3 import Web3, HTTPProvider
1721

18-
from fastlane_bot.events.interface import QueryInterface
1922
from fastlane_bot.events.managers.manager import Manager
2023
from fastlane_bot.events.multicall_utils import multicall_every_iteration
2124
from fastlane_bot.events.utils import (
@@ -47,7 +50,6 @@
4750
read_csv_file,
4851
handle_tokens_csv,
4952
)
50-
from fastlane_bot.tools.cpc import T
5153
from fastlane_bot.utils import find_latest_timestamped_folder
5254
from run_blockchain_terraformer import terraform_blockchain
5355

@@ -216,12 +218,7 @@
216218
"--blockchain",
217219
default="ethereum",
218220
help="Select a blockchain from the list. Blockchains not in this list do not have a deployed Fast Lane contract and are not supported.",
219-
type=click.Choice(
220-
[
221-
"ethereum",
222-
"coinbase_base"
223-
]
224-
),
221+
type=click.Choice(["ethereum", "coinbase_base"]),
225222
)
226223
@click.option(
227224
"--pool_data_update_frequency",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ click~=8.1.3
1717
setuptools~=67.6.1
1818
protobuf==3.19.5
1919
tqdm~=4.64.1
20-
20+
web3~=5.31.3

resources/NBTest/requirements.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
psutil==5.9.2
2+
packaging==21.3
3+
requests==2.28.1
4+
python-dateutil==2.8.1
5+
typing-extensions~=4.4.0
6+
python-dotenv~=0.16.0
7+
joblib~=1.2.0
8+
pandas~=1.5.2
9+
alchemy-sdk~=0.1.1
10+
pyarrow~=11.0.0
11+
networkx~=3.0
12+
cvxpy~=1.3.1
13+
matplotlib~=3.7.1
14+
dataclass_wizard~=0.22.2
15+
hexbytes~=0.2.3
16+
click~=8.1.3
17+
setuptools~=67.6.1
18+
protobuf==3.19.5
19+
tqdm~=4.64.1
20+
web3~=5.31.3

0 commit comments

Comments
 (0)