Skip to content
Open
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
97 changes: 67 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,89 @@
#!/usr/bin/env python
"""
@fileoverview Setup configuration for the aster-connector-python package, using setuptools.
This script manages package metadata, dependencies, and distribution settings.
"""
import os
import re
from setuptools import setup, find_packages
from typing import List

with open(
os.path.join(os.path.dirname(__file__), "requirements/common.txt"), "r"
) as fh:
requirements = fh.readlines()

# --- METADATA ---
NAME = "aster-connector-python"
DESCRIPTION = (
"This is a lightweight library that works as a connector to Aster Finance public API."
)
AUTHOR = ""
DESCRIPTION = "This is a lightweight library that works as a connector to Aster Finance public API."
AUTHOR = "The Asterdex Team" # Filled with organizational name
URL = "https://github.com/asterdex/aster-connector-python"
VERSION = "1.1.0"
LICENSE = "MIT"

# Resolve the base directory
ROOT = os.path.abspath(os.path.dirname(__file__))

# --- VERSIONING ---
# Use single source of truth for version by reading it from the package's __version__.py file.
# This ensures that the version in setup.py matches the version visible within the package.
def get_version() -> str:
"""Reads the version from the package's __version__.py file."""
version_file_path = os.path.join(ROOT, "aster", "__version__.py")
try:
with open(version_file_path, "r") as f:
version_match = re.search(r"^__version__\s*=\s*['\"]([^'\"]*)['\"]", f.read(), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
except FileNotFoundError:
# Fallback in case __version__.py doesn't exist yet (e.g., during building)
return "0.0.0"

# --- DEPENDENCY HANDLING ---

about = {}
def get_requirements(filename: str) -> List[str]:
"""Reads requirements from a file and cleans whitespace."""
filepath = os.path.join(ROOT, filename)
with open(filepath, "r") as fh:
# Filter out empty lines, comments, and clean whitespace
raw_requirements = fh.readlines()
requirements = [
req.strip()
for req in raw_requirements
if req.strip() and not req.startswith("#")
]
return requirements

with open("README.md", "r") as fh:
about["long_description"] = fh.read()
# Get requirements from the dedicated file
install_requirements = get_requirements("requirements/common.txt")

root = os.path.abspath(os.path.dirname(__file__))
# --- README CONTENT ---
with open(os.path.join(ROOT, "README.md"), "r", encoding="utf-8") as fh:
long_description = fh.read()

if not VERSION:
with open(os.path.join(root, "aster", "__version__.py")) as f:
exec(f.read(), about)
else:
about["__version__"] = VERSION

# --- SETUP ---
setup(
name=NAME,
version=about["__version__"],
license="MIT",
version=get_version(), # Dynamically read version
license=LICENSE,
description=DESCRIPTION,
long_description=about["long_description"],
long_description=long_description,
long_description_content_type="text/markdown",
AUTHOR=AUTHOR,
author=AUTHOR, # Updated Author field
url=URL,
keywords=["Aster", "Public API"],
install_requires=[req for req in requirements],
packages=find_packages(exclude=("tests",)),
keywords=["Aster", "Public API", "Decentralized Finance", "DeFi"],

# Use cleaned requirements list
install_requires=install_requirements,

packages=find_packages(exclude=("tests", "docs", "examples")), # Added common exclusions

# Update classifiers for actively supported Python versions (3.9+)
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Financial and Insurance Industry",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
python_requires=">=3.9", # Set minimum required Python to a currently supported version
)