Skip to content

Commit

Permalink
Move version to __init__,py
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNaif2018 committed Mar 21, 2023
1 parent dcf311b commit 255f803
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import importlib

from setuptools import setup

spec = importlib.util.spec_from_file_location("init", "tronpy/__init__.py")
init_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(init_module)

packages = ["tronpy", "tronpy.keys", "tronpy.providers"]

package_data = {"": ["*"]}
Expand All @@ -15,7 +21,7 @@

setup_kwargs = {
"name": "tronpy",
"version": "0.3.0",
"version": init_module.VERSION,
"description": "TRON Python client library",
"long_description": open("README.md").read(),
"long_description_content_type": "text/markdown",
Expand Down
3 changes: 2 additions & 1 deletion tronpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

TRX = 1_000_000
SUN = 1
VERSION = "0.3.0"

__all__ = ["Tron", "AsyncTron", "Contract", "AsyncContract", "ShieldedTRC20", "TRX", "SUN"]
__all__ = ["Tron", "AsyncTron", "Contract", "AsyncContract", "ShieldedTRC20", "TRX", "SUN", "VERSION"]
4 changes: 3 additions & 1 deletion tronpy/providers/async_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import httpx
from httpx import Timeout

from tronpy import VERSION

DEFAULT_TIMEOUT = 10.0
DEFAULT_API_KEY = "f92221d5-7056-4366-b96f-65d3662ec2d9"

Expand Down Expand Up @@ -36,7 +38,7 @@ def __init__(
else:
raise TypeError(f"unknown endpoint uri {endpoint_uri}")

headers = {"User-Agent": "Tronpy/0.2", "Tron-Pro-Api-Key": api_key}
headers = {"User-Agent": f"Tronpy/{VERSION}", "Tron-Pro-Api-Key": api_key}
if jw_token is not None:
headers["Authorization"] = f"Bearer {jw_token}"
if client is None:
Expand Down
4 changes: 3 additions & 1 deletion tronpy/providers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import requests

from tronpy import VERSION

DEFAULT_TIMEOUT = 10.0
DEFAULT_API_KEYS = [
"f92221d5-7056-4366-b96f-65d3662ec2d9",
Expand Down Expand Up @@ -61,7 +63,7 @@ def __init__(
self.jw_token = jw_token

self.sess = requests.session()
self.sess.headers["User-Agent"] = "Tronpy/0.2"
self.sess.headers["User-Agent"] = f"Tronpy/{VERSION}"

self.timeout = timeout
"""Request timeout in second."""
Expand Down

0 comments on commit 255f803

Please sign in to comment.