mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-13 20:47:53 -06:00
Compare commits
4 commits
c5d9d8cb65
...
80ae99c754
Author | SHA1 | Date | |
---|---|---|---|
80ae99c754 | |||
3a85fe4f3a | |||
ca67431a79 | |||
0b26c8cb48 |
4 changed files with 39 additions and 23 deletions
|
@ -8,8 +8,9 @@ A possible cli signature
|
||||||
viv shim black -o ~/bin/black
|
viv shim black -o ~/bin/black
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import viv
|
import viv
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -17,7 +17,7 @@ homepage = "https://github.com/daylinmorgan/viv"
|
||||||
repository = "https://github.com/daylinmorgan/viv"
|
repository = "https://github.com/daylinmorgan/viv"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
viv = "viv.viv:main"
|
viv = "viv:main"
|
||||||
|
|
||||||
[tool.pdm]
|
[tool.pdm]
|
||||||
version = { source = "scm" }
|
version = { source = "scm" }
|
||||||
|
@ -29,6 +29,7 @@ dev = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
select = ["E","F","I"]
|
||||||
ignore = ["E402"]
|
ignore = ["E402"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
from .viv import use, __version__ # noqa
|
from .viv import __version__, use, main # noqa
|
||||||
|
|
|
@ -21,17 +21,16 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from urllib.request import urlopen
|
|
||||||
from urllib.error import HTTPError
|
|
||||||
import venv
|
import venv
|
||||||
from argparse import SUPPRESS, Action
|
|
||||||
from argparse import ArgumentParser as StdArgParser
|
|
||||||
from argparse import (
|
from argparse import (
|
||||||
|
SUPPRESS,
|
||||||
|
Action,
|
||||||
HelpFormatter,
|
HelpFormatter,
|
||||||
Namespace,
|
Namespace,
|
||||||
RawDescriptionHelpFormatter,
|
RawDescriptionHelpFormatter,
|
||||||
_SubParsersAction,
|
_SubParsersAction,
|
||||||
)
|
)
|
||||||
|
from argparse import ArgumentParser as StdArgParser
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
|
@ -50,8 +49,10 @@ from typing import (
|
||||||
Tuple,
|
Tuple,
|
||||||
Type,
|
Type,
|
||||||
)
|
)
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
__version__ = "23.5a1"
|
__version__ = "23.5a1-3-g3a85fe4-dev"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -64,10 +65,8 @@ class Config:
|
||||||
srccache: Path = (
|
srccache: Path = (
|
||||||
Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "viv" / "src"
|
Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "viv" / "src"
|
||||||
)
|
)
|
||||||
srcdefault: Path = (
|
share: Path = (
|
||||||
Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share"))
|
Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share")) / "viv"
|
||||||
/ "viv"
|
|
||||||
/ "viv.py"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
def __post_init__(self) -> None:
|
||||||
|
@ -76,7 +75,8 @@ class Config:
|
||||||
parents=True,
|
parents=True,
|
||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
)
|
)
|
||||||
self.srcdefault.parent.mkdir(parents=True, exist_ok=True)
|
self.share.mkdir(parents=True, exist_ok=True)
|
||||||
|
self.srcdefault = self.share / "viv.py"
|
||||||
|
|
||||||
|
|
||||||
c = Config()
|
c = Config()
|
||||||
|
@ -466,12 +466,14 @@ class ViVenv:
|
||||||
def dump_info(self, write: bool = False) -> None:
|
def dump_info(self, write: bool = False) -> None:
|
||||||
# TODO: include associated files in 'info'
|
# TODO: include associated files in 'info'
|
||||||
# means it needs to be loaded first
|
# means it needs to be loaded first
|
||||||
|
# or keep a seperate file hash in c.share?
|
||||||
info = {
|
info = {
|
||||||
"created": str(datetime.today()),
|
"created": str(datetime.today()),
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
"spec": self.spec,
|
"spec": self.spec,
|
||||||
"exe": self.exe,
|
"exe": self.exe,
|
||||||
}
|
}
|
||||||
|
|
||||||
# save metadata to json file
|
# save metadata to json file
|
||||||
if write:
|
if write:
|
||||||
with (self.path / "viv-info.json").open("w") as f:
|
with (self.path / "viv-info.json").open("w") as f:
|
||||||
|
@ -1027,8 +1029,14 @@ class Viv:
|
||||||
"""manage viv itself"""
|
"""manage viv itself"""
|
||||||
|
|
||||||
if args.cmd == "show":
|
if args.cmd == "show":
|
||||||
|
if args.pythonpath:
|
||||||
|
if not self.local:
|
||||||
|
error("expected to find a local installation", exit=1)
|
||||||
|
else:
|
||||||
|
sys.stdout.write(str(self.local_source.parent) + "\n")
|
||||||
|
else:
|
||||||
echo("Current:")
|
echo("Current:")
|
||||||
sys.stdout.write(
|
sys.stderr.write(
|
||||||
SHOW_TEMPLATE.format(
|
SHOW_TEMPLATE.format(
|
||||||
version=__version__,
|
version=__version__,
|
||||||
cli=shutil.which("viv"),
|
cli=shutil.which("viv"),
|
||||||
|
@ -1256,10 +1264,16 @@ class Viv:
|
||||||
parents=[p_manage_shared],
|
parents=[p_manage_shared],
|
||||||
).set_defaults(func=self.manage, cmd="update")
|
).set_defaults(func=self.manage, cmd="update")
|
||||||
|
|
||||||
p_manage_sub.add_parser(
|
(
|
||||||
|
p_manage_show := p_manage_sub.add_parser(
|
||||||
"show", help="show current installation info", aliases="s"
|
"show", help="show current installation info", aliases="s"
|
||||||
|
)
|
||||||
).set_defaults(func=self.manage, cmd="show")
|
).set_defaults(func=self.manage, cmd="show")
|
||||||
|
|
||||||
|
p_manage_show.add_argument(
|
||||||
|
"-p", "--pythonpath", help="show the path/to/install", action="store_true"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
Loading…
Reference in a new issue