-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from bancorprotocol/207-fix-current-version-r…
…equirementstxt-file added version checker and requirements change
- Loading branch information
Showing
4 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from packaging import version as pkg_version | ||
from importlib.metadata import version | ||
|
||
|
||
class VersionRequirementError(Exception): | ||
""" | ||
A custom exception class for version requirement errors. | ||
Args: | ||
installed_version (str): The installed version of web3.py. | ||
required_version (str): The required version of web3.py. | ||
Raises: | ||
None | ||
""" | ||
|
||
def __init__(self, installed_version, required_version): | ||
super().__init__( | ||
f"" | ||
f"\n\n************** Version Requirement Error **************\n\n" | ||
f"Your current web3.py version is {installed_version}, which does not meet the requirement of ~= {required_version}.\n" | ||
f"Please upgrade your web3.py version to {required_version}.\n" | ||
f"We recommend using the latest requirements.txt file to install the latest versions of all " | ||
f"dependencies.\n\n" | ||
f"Run `pip install -r requirements.txt` from the project directory of the fastlane-bot repo.\n" | ||
f"\n\n************** Version Requirement Error **************\n\n" | ||
f"" | ||
) | ||
|
||
|
||
def check_version_requirements(): | ||
with open("requirements.txt", "r") as f: | ||
requirements = f.read().splitlines() | ||
|
||
web3_version = [r for r in requirements if "web3" in r][0] | ||
required_version = web3_version.split("~=")[1] | ||
|
||
# Get the installed version of web3 | ||
installed_version = version("web3") | ||
|
||
# Check the version and raise an exception if the requirement is not met | ||
if not pkg_version.parse(installed_version) <= pkg_version.parse("5.32.0"): | ||
raise VersionRequirementError(installed_version, required_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ click~=8.1.3 | |
setuptools~=67.6.1 | ||
protobuf==3.19.5 | ||
tqdm~=4.64.1 | ||
|
||
web3~=5.31.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
psutil==5.9.2 | ||
packaging==21.3 | ||
requests==2.28.1 | ||
python-dateutil==2.8.1 | ||
typing-extensions~=4.4.0 | ||
python-dotenv~=0.16.0 | ||
joblib~=1.2.0 | ||
pandas~=1.5.2 | ||
alchemy-sdk~=0.1.1 | ||
pyarrow~=11.0.0 | ||
networkx~=3.0 | ||
cvxpy~=1.3.1 | ||
matplotlib~=3.7.1 | ||
dataclass_wizard~=0.22.2 | ||
hexbytes~=0.2.3 | ||
click~=8.1.3 | ||
setuptools~=67.6.1 | ||
protobuf==3.19.5 | ||
tqdm~=4.64.1 | ||
web3~=5.31.3 |