mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 06:56:39 +03:00
build: keep the package version in tradingagents.__version__
- pyproject reads the version from tradingagents/__init__.py, so a source checkout, an editable install and a wheel report the same one - the SEC EDGAR User-Agent names tradingagents.__version__
This commit is contained in:
+4
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "tradingagents"
|
name = "tradingagents"
|
||||||
version = "0.5.2.dev0"
|
dynamic = ["version"]
|
||||||
description = "TradingAgents: Multi-Agents LLM Financial Trading Framework"
|
description = "TradingAgents: Multi-Agents LLM Financial Trading Framework"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
@@ -42,6 +42,9 @@ bedrock = [
|
|||||||
[project.scripts]
|
[project.scripts]
|
||||||
tradingagents = "cli.main:app"
|
tradingagents = "cli.main:app"
|
||||||
|
|
||||||
|
[tool.setuptools.dynamic]
|
||||||
|
version = {attr = "tradingagents.__version__"}
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
include = ["tradingagents*", "cli*"]
|
include = ["tradingagents*", "cli*"]
|
||||||
|
|
||||||
|
|||||||
+5
-15
@@ -221,22 +221,12 @@ def test_a_period_reported_under_two_tags_takes_the_preferred_one_not_both():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_the_default_identification_tracks_the_installed_version(monkeypatch):
|
def test_the_default_identification_names_the_package_version(monkeypatch):
|
||||||
"""A release should identify itself, not a version frozen in the source."""
|
"""SEC asks automated clients to identify themselves; a release names its own version."""
|
||||||
|
import tradingagents
|
||||||
|
|
||||||
monkeypatch.delenv("SEC_EDGAR_USER_AGENT", raising=False)
|
monkeypatch.delenv("SEC_EDGAR_USER_AGENT", raising=False)
|
||||||
monkeypatch.setattr(sec_edgar.metadata, "version", lambda name: "9.9.9")
|
assert sec_edgar._user_agent() == f"TradingAgents/{tradingagents.__version__} (contact@example.com)"
|
||||||
assert sec_edgar._user_agent() == "TradingAgents/9.9.9 (contact@example.com)"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
|
||||||
def test_an_uninstalled_checkout_still_identifies_itself(monkeypatch):
|
|
||||||
monkeypatch.delenv("SEC_EDGAR_USER_AGENT", raising=False)
|
|
||||||
|
|
||||||
def _missing(name):
|
|
||||||
raise sec_edgar.metadata.PackageNotFoundError(name)
|
|
||||||
|
|
||||||
monkeypatch.setattr(sec_edgar.metadata, "version", _missing)
|
|
||||||
assert "@" in sec_edgar._user_agent()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
"""The package version has one source, tradingagents.__version__, which the build reads."""
|
||||||
|
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import tradingagents
|
||||||
|
|
||||||
|
PYPROJECT = (Path(__file__).resolve().parents[1] / "pyproject.toml").read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_the_build_reads_the_version_from_the_package():
|
||||||
|
assert re.search(r'^dynamic = \["version"\]', PYPROJECT, re.M)
|
||||||
|
assert 'version = {attr = "tradingagents.__version__"}' in PYPROJECT
|
||||||
|
assert not re.search(r'^version = "', PYPROJECT, re.M)
|
||||||
|
assert re.fullmatch(r"\d+\.\d+\.\d+(\.dev\d+|rc\d+)?", tradingagents.__version__)
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
"""TradingAgents: multi-agent LLM financial trading framework."""
|
||||||
|
|
||||||
|
__version__ = "0.5.2.dev0"
|
||||||
|
|
||||||
from dotenv import find_dotenv, load_dotenv
|
from dotenv import find_dotenv, load_dotenv
|
||||||
|
|
||||||
# Load .env at package import so DEFAULT_CONFIG's env-var overlay and every LLM
|
# Load .env at package import so DEFAULT_CONFIG's env-var overlay and every LLM
|
||||||
|
|||||||
+2
-8
@@ -22,11 +22,11 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from importlib import metadata
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from tradingagents import __version__
|
||||||
from tradingagents.dataflows.config import get_config
|
from tradingagents.dataflows.config import get_config
|
||||||
from tradingagents.dataflows.errors import NoMarketDataError, VendorRateLimitError
|
from tradingagents.dataflows.errors import NoMarketDataError, VendorRateLimitError
|
||||||
|
|
||||||
@@ -93,15 +93,9 @@ def _user_agent() -> str:
|
|||||||
so SEC can reach you about your traffic rather than the project.
|
so SEC can reach you about your traffic rather than the project.
|
||||||
"""
|
"""
|
||||||
configured = os.getenv("SEC_EDGAR_USER_AGENT", "").strip()
|
configured = os.getenv("SEC_EDGAR_USER_AGENT", "").strip()
|
||||||
return configured or f"TradingAgents/{_version()} (contact@example.com)"
|
return configured or f"TradingAgents/{__version__} (contact@example.com)"
|
||||||
|
|
||||||
|
|
||||||
def _version() -> str:
|
|
||||||
"""The installed package version, so a release identifies itself correctly."""
|
|
||||||
try:
|
|
||||||
return metadata.version("tradingagents")
|
|
||||||
except metadata.PackageNotFoundError:
|
|
||||||
return "dev"
|
|
||||||
|
|
||||||
|
|
||||||
def _fetch_json(url: str) -> dict:
|
def _fetch_json(url: str) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user