Skip to content

Commit

Permalink
Get environments from tox.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 11, 2024
1 parent 684631a commit b6feaca
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/try_parser.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from tox.config.source.ini import IniSource
from tox.config.types import EnvList
from pathlib import Path
from ipdb import set_trace
from tox.config.cli.parse import get_options
from tox.session.state import State
from tox.config.sets import CoreConfigSet
from tox.config.source.tox_ini import ToxIni
from collections import defaultdict
from json import dumps

tox_ini_path = Path(
"/home/tigre/github/ocelotl/opentelemetry-python-contrib/tox.ini"
)

ini_source = IniSource(
Path("/home/tigre/github/ocelotl/opentelemetry-python-contrib/tox.ini")
)

tox_ini = ToxIni(tox_ini_path)

state = State(get_options(), [])

conf = state.conf
set_trace()

tox_section = [section for section in ini_source.sections()][0]

Expand All @@ -23,4 +31,12 @@

raw = tox_section_loader.load_raw("envlist", conf, None)

set_trace()
core_config_set = CoreConfigSet(conf, tox_section, tox_ini_path.parent, tox_ini_path)

loaders = tox_ini.get_loaders(tox_section, base=[], override_map=defaultdict(list, {}), conf=core_config_set)

core_config_set.loaders.extend(loaders)

result = core_config_set.load("env_list")

print(dumps(result.envs, indent=4))

0 comments on commit b6feaca

Please sign in to comment.