mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-11-09 19:13:14 -06:00
fix: setuptools correction for standalone
This commit is contained in:
parent
d6158137f2
commit
36c9706d76
2 changed files with 16 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# AUTOGENERATED by viv (v23.5a7-6-g5febbe0-dev)
|
# AUTOGENERATED by viv (v23.8a1-5-g4c782db-dev)
|
||||||
# see `python3 <(curl -fsSL viv.dayl.in/viv.py) --help`
|
# see `python3 <(curl -fsSL viv.dayl.in/viv.py) --help`
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,21 +14,19 @@ def _viv_use(*pkgs, track_exe=False, name=""):
|
||||||
|
|
||||||
meta = dict.fromkeys(("created", "accessed"), (t := str(datetime.today())))
|
meta = dict.fromkeys(("created", "accessed"), (t := str(datetime.today())))
|
||||||
runner = str(Path(__file__).absolute().resolve())
|
runner = str(Path(__file__).absolute().resolve())
|
||||||
env = lambda x: os.getenv(f"VIV_{x}") # noqa
|
envvar = lambda x: os.getenv(f"VIV_{x}") # noqa
|
||||||
F, V, no_st = map(env, ("FORCE", "VERBOSE", "NO_SETUPTOOLS"))
|
F, V, no_st = map(envvar, ("FORCE", "VERBOSE", "NO_SETUPTOOLS"))
|
||||||
xdg = os.getenv("XDG_CACHE_HOME")
|
base = Path(xdg) if (xdg := os.getenv("XDG_CACHE_HOME")) else Path.home() / ".cache"
|
||||||
cache = (Path(xdg) if xdg else Path.home() / ".cache") / "viv" / "venvs"
|
(cache := (base) / "viv/venvs").mkdir(parents=True, exist_ok=True)
|
||||||
cache.mkdir(parents=True, exist_ok=True)
|
|
||||||
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
||||||
(sha256 := hashlib.sha256()).update((str(spec := [*pkgs]) + exe).encode())
|
_id = hashlib.sha256((str(spec := [*pkgs]) + exe).encode()).hexdigest()
|
||||||
_id = sha256.hexdigest()
|
|
||||||
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
||||||
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
||||||
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
||||||
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
||||||
if (not no_st) and (not [x for x in spec if x.startswith("setuptools")]):
|
|
||||||
spec.append("setuptools")
|
|
||||||
cmd = ["pip", "--python", str(env / "bin" / "python"), "install", *spec]
|
cmd = ["pip", "--python", str(env / "bin" / "python"), "install", *spec]
|
||||||
|
if (not no_st) and (not [x for x in spec if x.startswith("setuptools")]):
|
||||||
|
cmd.append("setuptools")
|
||||||
p = run(cmd, **kw)
|
p = run(cmd, **kw)
|
||||||
if (rc := p.returncode) != 0:
|
if (rc := p.returncode) != 0:
|
||||||
if env.is_dir():
|
if env.is_dir():
|
||||||
|
|
|
@ -53,7 +53,7 @@ from typing import (
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
__version__ = "23.8a1-3-ga78624c-dev"
|
__version__ = "23.8a1-5-g4c782db-dev"
|
||||||
|
|
||||||
|
|
||||||
class Spinner:
|
class Spinner:
|
||||||
|
@ -340,21 +340,19 @@ class Template:
|
||||||
|
|
||||||
meta = dict.fromkeys(("created", "accessed"), (t := str(datetime.today())))
|
meta = dict.fromkeys(("created", "accessed"), (t := str(datetime.today())))
|
||||||
runner = str(Path(__file__).absolute().resolve())
|
runner = str(Path(__file__).absolute().resolve())
|
||||||
env = lambda x: os.getenv(f"VIV_{x}") # noqa
|
envvar = lambda x: os.getenv(f"VIV_{x}") # noqa
|
||||||
F, V, no_st = map(env, ("FORCE", "VERBOSE", "NO_SETUPTOOLS"))
|
F, V, no_st = map(envvar, ("FORCE", "VERBOSE", "NO_SETUPTOOLS"))
|
||||||
xdg = os.getenv("XDG_CACHE_HOME")
|
base = Path(xdg) if (xdg := os.getenv("XDG_CACHE_HOME")) else Path.home() / ".cache"
|
||||||
cache = (Path(xdg) if xdg else Path.home() / ".cache") / "viv" / "venvs"
|
(cache := (base) / "viv/venvs").mkdir(parents=True, exist_ok=True)
|
||||||
cache.mkdir(parents=True, exist_ok=True)
|
|
||||||
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
exe = str(Path(sys.executable).resolve()) if track_exe else "N/A"
|
||||||
(sha256 := hashlib.sha256()).update((str(spec := [*pkgs]) + exe).encode())
|
_id = hashlib.sha256((str(spec := [*pkgs]) + exe).encode()).hexdigest()
|
||||||
_id = sha256.hexdigest()
|
|
||||||
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
if (env := cache / (name if name else _id)) not in cache.glob("*/") or F:
|
||||||
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
sys.stderr.write(f"generating new vivenv -> {env.name}\n")
|
||||||
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
venv.create(env, prompt=f"viv-{name}", symlinks=True, clear=True)
|
||||||
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
kw = dict(zip(("stdout", "stderr"), ((None,) * 2 if V else (-1, 2))))
|
||||||
if (not no_st) and (not [x for x in spec if x.startswith("setuptools")]):
|
|
||||||
spec.append("setuptools")
|
|
||||||
cmd = ["pip", "--python", str(env / "bin" / "python"), "install", *spec]
|
cmd = ["pip", "--python", str(env / "bin" / "python"), "install", *spec]
|
||||||
|
if (not no_st) and (not [x for x in spec if x.startswith("setuptools")]):
|
||||||
|
cmd.append("setuptools")
|
||||||
p = run(cmd, **kw)
|
p = run(cmd, **kw)
|
||||||
if (rc := p.returncode) != 0:
|
if (rc := p.returncode) != 0:
|
||||||
if env.is_dir():
|
if env.is_dir():
|
||||||
|
|
Loading…
Reference in a new issue