#!/usr/bin/env python3

import glob
import os
import runpy
import shutil
import subprocess
import sys
import typing as tp
from pathlib import Path

here = Path(__file__).parent
manager = runpy.run_path(str(Path(__file__).parent / "bootstrap_venvstarter.py"))["manager"]


def run(venv_location: Path, args: tp.List[str]) -> tp.Union[None, str, tp.List[str]]:
    devtools_location = Path(__file__).parent / "devtools.py"
    return ["python", str(devtools_location)]


manager = manager(run).named(".python")

manager.add_local_dep(
    "{here}",
    "..",
    version_file=("dict2xml", "version.py"),
    name="dict2xml=={version}",
    with_tests=True,
)

if "TOX_PYTHON" in os.environ:
    folder = Path(os.environ["TOX_PYTHON"]).parent.parent
    manager.place_venv_in(folder.parent)
    manager.named(folder.name)
else:
    manager.add_no_binary("black")
    manager.add_requirements_file("{here}", "requirements.dev.txt")
    manager.add_env(NOSE_OF_YETI_BLACK_COMPAT="true")

manager.run()
