mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-12 12:13:15 -06:00
Compare commits
2 commits
e26922b808
...
0cc9faa221
Author | SHA1 | Date | |
---|---|---|---|
0cc9faa221 | |||
044a22901b |
4 changed files with 64 additions and 22 deletions
19
Makefile
19
Makefile
|
@ -1,12 +1,6 @@
|
|||
VERSION ?= $(shell git describe --tags --always --dirty=-dev | sed 's/^v//g')
|
||||
PREFIX ?= ~/bin
|
||||
|
||||
lint: ## run pre-commit hooks
|
||||
pdm run pre-commit run --all || pdm run pre-commit run --all
|
||||
|
||||
types: ## run mypy
|
||||
pdm run mypy src/viv
|
||||
|
||||
bump: ## update version and tag commit
|
||||
@echo "bumping to version => $(VERSION)"
|
||||
@sed -i 's/__version__ = ".*"/__version__ = "$(VERSION)"/g' src/viv/viv.py
|
||||
|
@ -25,18 +19,15 @@ assets/viv-help.svg:
|
|||
dev-install:
|
||||
ln -sf $(PWD)/src/viv/viv.py ~/.local/share/viv/viv.py
|
||||
|
||||
docs: docs/index.md docs/viv.py ## build docs
|
||||
pdm run mkdocs build
|
||||
|
||||
svgs: ## build svgs for docs
|
||||
pdm run python ./scripts/generate-svgs.py
|
||||
## docs |> update docs files
|
||||
docs: docs/viv.py docs/index.md
|
||||
|
||||
docs/viv.py: src/viv/viv.py
|
||||
cp $< $@
|
||||
@cp $< $@
|
||||
|
||||
docs/index.md: README.md
|
||||
printf -- '---\nhide: [navigation]\n---\n\n' > $@
|
||||
cat $< >> $@
|
||||
@printf -- '---\nhide: [navigation]\n---\n\n' > $@
|
||||
@cat $< >> $@
|
||||
|
||||
examples/black: .FORCE
|
||||
rm -f $@
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
# AUTOGENERATED by viv (v23.8a1-5-g4c782db-dev)
|
||||
# AUTOGENERATED by viv (v23.8b2-6-gdafa099-dev)
|
||||
# see `python3 <(curl -fsSL viv.dayl.in/viv.py) --help`
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ def _viv_use(*pkgs, track_exe=False, name=""):
|
|||
(cache := (base) / "viv/venvs").mkdir(parents=True, exist_ok=True)
|
||||
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
||||
_id = hashlib.sha256((str(spec := [*pkgs]) + exe).encode()).hexdigest()
|
||||
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
||||
if (env := cache / (name if name else _id[:8])) not in cache.glob("*/") or F:
|
||||
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
||||
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
||||
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
||||
|
@ -49,7 +49,7 @@ import sys
|
|||
if __name__ == "__main__":
|
||||
vivenv = _viv_use(
|
||||
"black==23.7.0",
|
||||
"click==8.1.6",
|
||||
"click==8.1.7",
|
||||
"mypy-extensions==1.0.0",
|
||||
"packaging==23.1", # noqa
|
||||
"pathspec==0.11.2",
|
||||
|
|
45
noxfile.py
Normal file
45
noxfile.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import nox
|
||||
|
||||
nox.options.reuse_existing_virtualenvs = True
|
||||
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
|
||||
|
||||
def pdm_install(session,group):
|
||||
session.run_always("pdm", "install", "-G", group, external=True, silent=True)
|
||||
|
||||
|
||||
@nox.session
|
||||
def lint(session):
|
||||
pdm_install(session,"dev")
|
||||
session.run("pre-commit", "run")
|
||||
session.run("mypy", "src/")
|
||||
|
||||
@nox.session
|
||||
def svgs(session):
|
||||
pdm_install(session, "docs")
|
||||
session.run("./scripts/generate-svgs.py", external=True)
|
||||
|
||||
@nox.session
|
||||
def docs(session):
|
||||
pdm_install(session,"docs")
|
||||
if not Path('docs/svgs').is_dir():
|
||||
svgs(session)
|
||||
|
||||
session.run("make","docs", external=True)
|
||||
if session.interactive:
|
||||
session.run("mkdocs","serve")
|
||||
else:
|
||||
session.run("mkdocs","build")
|
||||
|
||||
|
||||
# @nox.session(
|
||||
# python=["3.8", "3.9", "3.10", "3.11"]
|
||||
# )
|
||||
# def test(session):
|
||||
# pdm_install(session,'test')
|
||||
# session.run('pytest')
|
||||
#
|
|
@ -52,7 +52,7 @@ from typing import (
|
|||
Union,
|
||||
)
|
||||
|
||||
__version__ = "23.8b2-6-gdafa099-dev"
|
||||
__version__ = "23.8b2-9-g044a229-dev"
|
||||
|
||||
|
||||
class Spinner:
|
||||
|
@ -357,7 +357,7 @@ class Template:
|
|||
(cache := (base) / "viv/venvs").mkdir(parents=True, exist_ok=True)
|
||||
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
||||
_id = hashlib.sha256((str(spec := [*pkgs]) + exe).encode()).hexdigest()
|
||||
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
||||
if (env := cache / (name if name else _id[:8])) not in cache.glob("*/") or F:
|
||||
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
||||
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
||||
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
||||
|
@ -1124,13 +1124,19 @@ def resolve_deps(reqs: List[str], requirements: Path) -> List[str]:
|
|||
"--dry-run",
|
||||
"--quiet",
|
||||
"--ignore-installed",
|
||||
"--disable-pip-version-check",
|
||||
"--report",
|
||||
"-",
|
||||
] + spec
|
||||
try:
|
||||
result = subprocess_run(cmd, check_output=True, spinmsg="resolving depedencies")
|
||||
report = json.loads(result)
|
||||
except json.JSONDecodeError:
|
||||
err_quit(
|
||||
f"failed to parse result from cmd: {a.bold}{' '.join(cmd)}{a.end}\n"
|
||||
"see viv log for output"
|
||||
)
|
||||
|
||||
report = json.loads(
|
||||
subprocess_run(cmd, check_output=True, spinmsg="resolving depedencies")
|
||||
)
|
||||
resolved_spec = [
|
||||
f"{pkg['metadata']['name']}=={pkg['metadata']['version']}"
|
||||
for pkg in report["install"]
|
||||
|
|
Loading…
Reference in a new issue