Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix __version_as_int__ for >10 minor/patch release vers (resolves #1982) #1993

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@
# Bittensor code and protocol version.
__version__ = "7.0.0"

version_split = __version__.split(".")
__version_as_int__: int = (
(100 * int(version_split[0]))
+ (10 * int(version_split[1]))
+ (1 * int(version_split[2]))
_version_split = __version__.split(".")
__version_info__ = tuple(int(part) for part in _version_split)
_version_int_base = 1000
assert max(__version_info__) < _version_int_base

__version_as_int__: int = sum(
e * (_version_int_base**i) for i, e in enumerate(reversed(__version_info__))
)
assert __version_as_int__ < 2**31 # fits in int32
__new_signature_version__ = 360

# Rich console.
Expand All @@ -58,6 +61,16 @@
install(show_locals=False)


def __getattr__(name):
if name == "version_split":
warnings.warn(
"version_split is deprecated and will be removed in future versions. Use __version__ instead.",
DeprecationWarning,
)
return _version_split
raise AttributeError(f"module {__name__} has no attribute {name}")


def turn_console_off():
global __use_console__
global __console__
Expand Down
Loading