| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
from pathlib import Path |
| 4 |
import typing as tp |
| 5 |
import subprocess |
| 6 |
import shutil |
| 7 |
import runpy |
| 8 |
import glob |
| 9 |
import sys |
| 10 |
import os |
| 11 |
|
| 12 |
here = Path(__file__).parent |
| 13 |
manager = runpy.run_path(str(Path(__file__).parent / "bootstrap_venvstarter.py"))["manager"] |
| 14 |
|
| 15 |
|
| 16 |
def run(venv_location: Path, args: tp.List[str]) -> tp.Union[None, str, tp.List[str]]: |
| 17 |
os.environ["NOSE_OF_YETI_BLACK_COMPAT"] = "true" |
| 18 |
|
| 19 |
for dr in Path(venv_location / "lib").iterdir(): |
| 20 |
if dr.name.startswith("python"): |
| 21 |
pth_file = dr / "site-packages" / "noy_black.pth" |
| 22 |
if not pth_file.exists(): |
| 23 |
pth_file.symlink_to(here / ".." / "noseOfYeti" / "black" / "noy_black.pth") |
| 24 |
break |
| 25 |
|
| 26 |
devtools_location = Path(__file__).parent / "devtools.py" |
| 27 |
return ["python", str(devtools_location)] |
| 28 |
|
| 29 |
|
| 30 |
manager = manager(run).named(".python") |
| 31 |
manager.add_no_binary("black") |
| 32 |
manager.add_env(NOSE_OF_YETI_BLACK_COMPAT="true") |
| 33 |
manager.add_local_dep( |
| 34 |
"{here}", |
| 35 |
"..", |
| 36 |
version_file=( |
| 37 |
"noseOfYeti", |
| 38 |
"version.py", |
| 39 |
), |
| 40 |
name="noseOfYeti[black,tests]=={version}", |
| 41 |
) |
| 42 |
|
| 43 |
if "TOX_PYTHON" in os.environ: |
| 44 |
folder = Path(os.environ["TOX_PYTHON"]).parent.parent |
| 45 |
manager.place_venv_in(folder.parent) |
| 46 |
manager.named(folder.name) |
| 47 |
else: |
| 48 |
manager.add_no_binary("black") |
| 49 |
manager.add_requirements_file("{here}", "requirements.dev.txt") |
| 50 |
manager.add_requirements_file("{here}", "requirements.docs.txt") |
| 51 |
|
| 52 |
manager.run() |