mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-26 19:50:45 -06:00
Compare commits
3 commits
c5bc03f497
...
1b8bcb4454
Author | SHA1 | Date | |
---|---|---|---|
1b8bcb4454 | |||
c43f2f027c | |||
4c236e96eb |
2 changed files with 30 additions and 16 deletions
|
@ -131,12 +131,13 @@ PACKAGES = [
|
|||
Package(
|
||||
name="packaging",
|
||||
url="https://github.com/pypa/packaging.git",
|
||||
rev="23.2",
|
||||
# v24.0
|
||||
rev="7a983f7f0068669ead9d4f7571be24d6c0d83eb9",
|
||||
files=(
|
||||
("_structures", [[5, 61]]),
|
||||
("version", [[17, 563]]),
|
||||
("utils", [[54, 100]]),
|
||||
("specifiers", [[28, 1030]]),
|
||||
("specifiers", [[18, 1017]]),
|
||||
),
|
||||
basepath=Path(__file__).parent / "packaging/src/packaging",
|
||||
prefix="""
|
||||
|
|
|
@ -1363,7 +1363,7 @@ class v_packaging_Specifier(v_packaging_BaseSpecifier):
|
|||
)
|
||||
self._prereleases = prereleases
|
||||
|
||||
@property # type: ignore
|
||||
@property
|
||||
def prereleases(self) -> bool:
|
||||
if self._prereleases is not None:
|
||||
return self._prereleases
|
||||
|
@ -1425,7 +1425,7 @@ class v_packaging_Specifier(v_packaging_BaseSpecifier):
|
|||
return operator_callable
|
||||
|
||||
def _compare_compatible(self, prospective: v_packaging_Version, spec: str) -> bool:
|
||||
prefix = ".".join(
|
||||
prefix = v_packaging__version_join(
|
||||
list(
|
||||
itertools.takewhile(
|
||||
v_packaging__is_not_suffix, v_packaging__version_split(spec)
|
||||
|
@ -1549,7 +1549,9 @@ v_packaging__prefix_regex = re.compile("^([0-9]+)((?:a|b|c|rc)[0-9]+)$")
|
|||
|
||||
def v_packaging__version_split(version: str) -> List[str]:
|
||||
result: List[str] = []
|
||||
for item in version.split("."):
|
||||
epoch, _, rest = version.rpartition("!")
|
||||
result.append(epoch or "0")
|
||||
for item in rest.split("."):
|
||||
match = v_packaging__prefix_regex.search(item)
|
||||
if match:
|
||||
result.extend(match.groups())
|
||||
|
@ -1558,6 +1560,11 @@ def v_packaging__version_split(version: str) -> List[str]:
|
|||
return result
|
||||
|
||||
|
||||
def v_packaging__version_join(components: List[str]) -> str:
|
||||
epoch, *rest = components
|
||||
return f"{epoch}!{'.'.join(rest)}"
|
||||
|
||||
|
||||
def v_packaging__is_not_suffix(segment: str) -> bool:
|
||||
return not any(
|
||||
segment.startswith(prefix) for prefix in ("dev", "a", "b", "rc", "post")
|
||||
|
@ -1574,7 +1581,9 @@ def v_packaging__pad_version(
|
|||
right_split.append(right[len(right_split[0]) :])
|
||||
left_split.insert(1, ["0"] * max(0, len(right_split[0]) - len(left_split[0])))
|
||||
right_split.insert(1, ["0"] * max(0, len(left_split[0]) - len(right_split[0])))
|
||||
return list(itertools.chain(*left_split)), list(itertools.chain(*right_split))
|
||||
return list(itertools.chain.from_iterable(left_split)), list(
|
||||
itertools.chain.from_iterable(right_split)
|
||||
)
|
||||
|
||||
|
||||
class v_packaging_SpecifierSet(v_packaging_BaseSpecifier):
|
||||
|
@ -1582,10 +1591,7 @@ class v_packaging_SpecifierSet(v_packaging_BaseSpecifier):
|
|||
self, specifiers: str = "", prereleases: Optional[bool] = None
|
||||
) -> None:
|
||||
split_specifiers = [s.strip() for s in specifiers.split(",") if s.strip()]
|
||||
v_packaging_parsed: Set[v_packaging_Specifier] = set()
|
||||
for specifier in split_specifiers:
|
||||
v_packaging_parsed.add(v_packaging_Specifier(specifier))
|
||||
self._specs = frozenset(v_packaging_parsed)
|
||||
self._specs = frozenset(map(v_packaging_Specifier, split_specifiers))
|
||||
self._prereleases = prereleases
|
||||
|
||||
@property
|
||||
|
@ -1631,7 +1637,7 @@ class v_packaging_SpecifierSet(v_packaging_BaseSpecifier):
|
|||
specifier._prereleases = self._prereleases
|
||||
else:
|
||||
raise ValueError(
|
||||
"Cannot combine v_packaging_SpecifierSets "
|
||||
"Cannot combine v_packaging_SpecifierSets"
|
||||
"with True and False prerelease overrides."
|
||||
)
|
||||
return specifier
|
||||
|
@ -3452,9 +3458,9 @@ class Viv:
|
|||
"`python3 <(curl -fsSL viv.dayl.in/viv.py) manage install`"
|
||||
)
|
||||
|
||||
def _pick_bin(self, reqs: List[str], bin: str) -> Tuple[str, str]:
|
||||
def _pick_bin(self, reqs: List[str], bin: str) -> str:
|
||||
default = system.bin(re.split(r"[=><~!*]+", reqs[0])[0])
|
||||
return default, (default if not bin else bin)
|
||||
return default if not bin else bin
|
||||
|
||||
def cmd_shim(
|
||||
self,
|
||||
|
@ -3463,6 +3469,7 @@ class Viv:
|
|||
bin: str,
|
||||
output: Path,
|
||||
freeze: bool,
|
||||
generate: bool,
|
||||
yes: bool,
|
||||
path: str,
|
||||
standalone: bool,
|
||||
|
@ -3475,8 +3482,8 @@ class Viv:
|
|||
viv shim yartsu -o ~/bin/yartsu --standalone
|
||||
"""
|
||||
|
||||
default_bin, bin = self._pick_bin(reqs, bin)
|
||||
output = Env().viv_bin_dir / default_bin if not output else output.absolute()
|
||||
bin = self._pick_bin(reqs, bin)
|
||||
output = Env().viv_bin_dir / bin if not output else output.absolute()
|
||||
|
||||
if freeze:
|
||||
spec = resolve_deps(reqs, requirements)
|
||||
|
@ -3494,6 +3501,11 @@ class Viv:
|
|||
with output.open("w") as f:
|
||||
f.write(self.t.shim(path, self.local_source, standalone, spec, bin))
|
||||
make_executable(output)
|
||||
if generate:
|
||||
vivenv = ViVenv(spec)
|
||||
with vivenv.use():
|
||||
vivenv.meta.addfile(output)
|
||||
vivenv.meta.write()
|
||||
|
||||
def cmd_run(
|
||||
self,
|
||||
|
@ -3520,7 +3532,7 @@ class Viv:
|
|||
if script:
|
||||
Script(path=script, spec=spec, keep=keep, rest=rest, viv=self).run()
|
||||
else:
|
||||
_, bin = self._pick_bin(reqs, bin)
|
||||
bin = self._pick_bin(reqs, bin)
|
||||
vivenv = ViVenv(spec)
|
||||
|
||||
with vivenv.use(keep=keep):
|
||||
|
@ -3577,6 +3589,7 @@ class Cli:
|
|||
),
|
||||
],
|
||||
("shim",): [
|
||||
BoolArg(flag="generate", help="create vivenv w/shim"),
|
||||
BoolArg(
|
||||
flag="freeze",
|
||||
help="freeze/resolve all dependencies",
|
||||
|
|
Loading…
Reference in a new issue