mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-22 02:30:44 -06:00
chore: switch to swydd
This commit is contained in:
parent
c5bc03f497
commit
f6f4c9df4b
4 changed files with 80 additions and 50 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -178,3 +178,5 @@ docs/public
|
|||
/tests/.viv-cache
|
||||
/scripts/tomli
|
||||
/scripts/packaging
|
||||
|
||||
swydd
|
||||
|
|
|
@ -50,11 +50,6 @@ def docs(session):
|
|||
session.run("sphinx-build", "docs", "site")
|
||||
|
||||
|
||||
@nox.session
|
||||
def release(session):
|
||||
session.run("./scripts/release.py", external=True)
|
||||
|
||||
|
||||
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
|
||||
def test(session):
|
||||
pdm_install(session, "test")
|
||||
|
|
45
task
45
task
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# VERSION = $(git describe --tags --always --dirty=-dev | sed 's/^v//g')
|
||||
|
||||
function task:venv {
|
||||
: "setup up pdm venv"
|
||||
pdm install
|
||||
}
|
||||
|
||||
function task:dev-install {
|
||||
: "symlink development version"
|
||||
mkdir -p ~/.local/share/viv
|
||||
mkdir -p ~/.local/bin
|
||||
ln -sf "$(pwd)/src/viv/viv.py" ~/.local/share/viv/viv.py
|
||||
ln -sf ~/.local/share/viv/viv.py ~/.local/bin/viv
|
||||
}
|
||||
|
||||
function task:_black {
|
||||
: "generate black example shim"
|
||||
rm -f examples/black
|
||||
viv shim black -y -s -f -o examples/black
|
||||
}
|
||||
|
||||
function task:clean {
|
||||
: "clean build artifacts"
|
||||
rm -rf build dist
|
||||
}
|
||||
|
||||
function task:examples {
|
||||
: "run examples to generate vivenvs"
|
||||
examples="cli sys_path exe_specific frozen_import named_env scrape"
|
||||
for f in $examples; do
|
||||
python "examples/$f.py"
|
||||
done
|
||||
}
|
||||
|
||||
function task:_help-logo {
|
||||
FORCE_COLOR=1 viv --help | yartsu -t 'viv --help' -w 70 -o assets/viv-help.svg
|
||||
}
|
||||
|
||||
# ---- do-task boilerplate ----
|
||||
function task:help { : "Show this help"; echo "do:";w=$(("$(compgen -A function | wc -L)" - 3));while read -r name; do [[ ! $name =~ ^task:_ ]] && [[ $name =~ ^task: ]] && paste <(printf '\033[1;32m%*s\033[0m\n' "$w" "${name#task:}") <(type "$name" | sed -nEe 's/^[[:space:]]*: ?"(.*)";/\1/p'); done < <(compgen -A function); }
|
||||
while read -r name; do [[ $name == "task:$1" ]] && { shift; task="$name"; }; done < <(compgen -A function)
|
||||
[[ -n "$1" && -z "$task" ]] && printf "\033[1;31m%s\033\0[m is not a task\n" "$1"
|
||||
"${task:-task:help}" "$@" && exit "$?"
|
78
tasks.py
Executable file
78
tasks.py
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python3
|
||||
# # https://github.com/daylinmorgan/swydd?tab=readme-ov-file#automagic-snippet
|
||||
# fmt: off
|
||||
if not (src := __import__("pathlib").Path(__file__).parent / "swydd/__init__.py").is_file(): # noqa
|
||||
try: __import__("swydd") # noqa
|
||||
except ImportError:
|
||||
import sys; from urllib.request import urlopen; from urllib.error import URLError # noqa
|
||||
try: r = urlopen("https://raw.githubusercontent.com/daylinmorgan/swydd/main/src/swydd/__init__.py") # noqa
|
||||
except URLError as e: sys.exit(f"error fetching swydd: {e}\n") # noqa
|
||||
src.parent.mkdir(exists_ok=True); src.write_text(r.read().decode("utf-8")); # noqa
|
||||
# fmt: on
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import swydd as s
|
||||
|
||||
|
||||
@s.task
|
||||
def venv():
|
||||
"""setup up pdm venv"""
|
||||
s.sh("pdm install")
|
||||
|
||||
|
||||
@s.task
|
||||
def dev():
|
||||
"""symlink development version"""
|
||||
s.sh(f"mkdir -p {Path.home()}/.local/share/viv")
|
||||
s.sh(f"mkdir -p {Path.home()}/.local/bin")
|
||||
s.sh(
|
||||
f"""ln -sf {Path.cwd()}/src/viv/viv.py """
|
||||
f"""{Path.home()}/.local/share/viv/viv.py"""
|
||||
)
|
||||
s.sh(f"ln -sf {Path.home()}/.local/share/viv/viv.py {Path.home()}/.local/bin/viv")
|
||||
|
||||
|
||||
@s.targets("assets/viv-help.svg")
|
||||
def _():
|
||||
s.sh(
|
||||
"FORCE_COLOR=1 viv --help | "
|
||||
"yartsu -t 'viv --help' -w 70 -o assets/viv-help.svg",
|
||||
shell=True,
|
||||
)
|
||||
|
||||
|
||||
@s.targets("examples/black")
|
||||
@s.needs("src/viv/viv.py")
|
||||
def _():
|
||||
s.sh("rm -f examples/black")
|
||||
s.sh("viv shim black -y -s -f -o examples/black")
|
||||
|
||||
|
||||
@s.task
|
||||
def clean():
|
||||
"""clean build artifacts"""
|
||||
s.sh("rm -rf build dist")
|
||||
|
||||
|
||||
@s.task
|
||||
@s.option("names", "list of names (comma-seperated)")
|
||||
def examples(names: str = "cli,sys_path,exe_specific,frozen_import,named_env,scrape"):
|
||||
"""run examples to generate vivenvs"""
|
||||
name_list = names.split(",")
|
||||
for name in name_list:
|
||||
s.sh(f"python examples/{name}.py")
|
||||
|
||||
|
||||
@s.task
|
||||
def release():
|
||||
"""generate new release"""
|
||||
s.sh("./scripts/release.py")
|
||||
|
||||
|
||||
print(s.ctx._tasks.items())
|
||||
for id_, task in s.ctx._tasks.items():
|
||||
print(task.name)
|
||||
print(task.targets)
|
||||
print(task.needs)
|
||||
s.cli()
|
Loading…
Reference in a new issue