Skip to content

Commit cf15a09

Browse files
committed
Drop relenv build --check-versions
relenv build --check-versions is now superseeded by relenv versions --check-deps. The new dependency tracking via --check-deps and --update-deps will allow us to more easily maintain relenv moving forwared
1 parent 01af72b commit cf15a09

File tree

3 files changed

+2
-203
lines changed

3 files changed

+2
-203
lines changed

relenv/build/__init__.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from types import FrameType, ModuleType
1515

1616
from . import darwin, linux, windows
17-
from .common import CHECK_VERSIONS_SUPPORT, builds
17+
from .common import builds
1818
from ..common import DEFAULT_PYTHON, build_arch
1919
from ..pyversions import Version, python_versions
2020

@@ -105,12 +105,6 @@ def setup_parser(
105105
"has no chance of being succesful. "
106106
),
107107
)
108-
build_subparser.add_argument(
109-
"--check-versions",
110-
default=False,
111-
action="store_true",
112-
help="Check for new version of python and it's depenencies, then exit.",
113-
)
114108
build_subparser.add_argument(
115109
"--no-pretty",
116110
default=False,
@@ -176,18 +170,6 @@ def main(args: argparse.Namespace) -> None:
176170
build.recipies["python"]["download"].version = str(build_version)
177171
build.recipies["python"]["download"].checksum = pyversions[build_version]
178172

179-
if args.check_versions:
180-
if not CHECK_VERSIONS_SUPPORT:
181-
print(
182-
"Check versions not supported. Please install the "
183-
"packaging and looseversion python packages."
184-
)
185-
sys.exit(2)
186-
if not build.check_versions():
187-
sys.exit(1)
188-
else:
189-
sys.exit(0)
190-
191173
build.set_arch(args.arch)
192174
if build.build_arch != build.arch:
193175
print(

relenv/build/common.py

Lines changed: 1 addition & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import tempfile
2323
import time
2424
import tarfile
25-
from html.parser import HTMLParser
2625
from types import ModuleType
2726
from typing import (
2827
Any,
@@ -38,7 +37,7 @@
3837
cast,
3938
)
4039

41-
from typing import TYPE_CHECKING, Protocol, TypedDict
40+
from typing import TYPE_CHECKING, TypedDict
4241

4342
if TYPE_CHECKING:
4443
from multiprocessing.synchronize import Event as SyncEvent
@@ -59,7 +58,6 @@
5958
get_triplet,
6059
runcmd,
6160
work_dirs,
62-
fetch_url,
6361
Version,
6462
WorkDirs,
6563
)
@@ -68,14 +66,6 @@
6866

6967
PathLike = Union[str, os.PathLike[str]]
7068

71-
72-
CHECK_VERSIONS_SUPPORT = True
73-
try:
74-
from packaging.version import InvalidVersion, parse
75-
from looseversion import LooseVersion
76-
except ImportError:
77-
CHECK_VERSIONS_SUPPORT = False
78-
7969
log = logging.getLogger(__name__)
8070

8171

@@ -505,8 +495,6 @@ def patch_file(path: PathLike, old: str, new: str) -> None:
505495
:type path: str
506496
"""
507497
log.debug("Patching file: %s", path)
508-
import re
509-
510498
with open(path, "r") as fp:
511499
content = fp.read()
512500
new_content = ""
@@ -517,48 +505,6 @@ def patch_file(path: PathLike, old: str, new: str) -> None:
517505
fp.write(new_content)
518506

519507

520-
def tarball_version(href: str) -> Optional[str]:
521-
if href.endswith("tar.gz"):
522-
try:
523-
x = href.split("-", 1)[1][:-7]
524-
if x != "latest":
525-
return x
526-
except IndexError:
527-
return None
528-
return None
529-
530-
531-
def sqlite_version(href: str) -> Optional[str]:
532-
if "releaselog" in href:
533-
link = href.split("/")[1][:-5]
534-
return "{:d}{:02d}{:02d}00".format(*[int(_) for _ in link.split("_")])
535-
return None
536-
537-
538-
def github_version(href: str) -> Optional[str]:
539-
if "tag/" in href:
540-
return href.split("/v")[-1]
541-
return None
542-
543-
544-
def krb_version(href: str) -> Optional[str]:
545-
if re.match(r"\d\.\d\d/", href):
546-
return href[:-1]
547-
return None
548-
549-
550-
def python_version(href: str) -> Optional[str]:
551-
if re.match(r"(\d+\.)+\d/", href):
552-
return href[:-1]
553-
return None
554-
555-
556-
def uuid_version(href: str) -> Optional[str]:
557-
if "download" in href and "latest" not in href:
558-
return href[:-16].rsplit("/")[-1].replace("libuuid-", "")
559-
return None
560-
561-
562508
def get_dependency_version(name: str, platform: str) -> Optional[Dict[str, str]]:
563509
"""
564510
Get dependency version and metadata from python-versions.json.
@@ -605,81 +551,6 @@ def get_dependency_version(name: str, platform: str) -> Optional[Dict[str, str]]
605551
return None
606552

607553

608-
def parse_links(text: str) -> List[str]:
609-
class HrefParser(HTMLParser):
610-
def __init__(self) -> None:
611-
super().__init__()
612-
self.hrefs: List[str] = []
613-
614-
def handle_starttag(
615-
self, tag: str, attrs: List[Tuple[str, Optional[str]]]
616-
) -> None:
617-
if tag == "a":
618-
link = dict(attrs).get("href")
619-
if link:
620-
self.hrefs.append(link)
621-
622-
parser = HrefParser()
623-
parser.feed(text)
624-
return parser.hrefs
625-
626-
627-
class Comparable(Protocol):
628-
"""Protocol capturing the comparison operations we rely on."""
629-
630-
def __lt__(self, other: Any) -> bool:
631-
"""Return True when self is ordered before *other*."""
632-
633-
def __gt__(self, other: Any) -> bool:
634-
"""Return True when self is ordered after *other*."""
635-
636-
637-
def check_files(
638-
name: str,
639-
location: str,
640-
func: Optional[Callable[[str], Optional[str]]],
641-
current: str,
642-
) -> None:
643-
fp = io.BytesIO()
644-
fetch_url(location, fp)
645-
fp.seek(0)
646-
text = fp.read().decode()
647-
loose = False
648-
current_version: Comparable
649-
try:
650-
current_version = cast(Comparable, parse(current))
651-
except InvalidVersion:
652-
current_version = LooseVersion(current)
653-
loose = True
654-
655-
versions: List[Comparable] = []
656-
if func is None:
657-
return
658-
for link in parse_links(text):
659-
version = func(link)
660-
if version:
661-
if loose:
662-
versions.append(LooseVersion(version))
663-
else:
664-
try:
665-
versions.append(cast(Comparable, parse(version)))
666-
except InvalidVersion:
667-
pass
668-
versions.sort()
669-
compare_versions(name, current_version, versions)
670-
671-
672-
def compare_versions(
673-
name: str, current: Comparable, versions: Sequence[Comparable]
674-
) -> None:
675-
for version in versions:
676-
try:
677-
if version > current:
678-
print(f"Found new version of {name} {version} > {current}")
679-
except TypeError:
680-
print(f"Unable to compare versions {version}")
681-
682-
683554
class Download:
684555
"""
685556
A utility that holds information about content to be downloaded.
@@ -708,8 +579,6 @@ def __init__(
708579
destination: PathLike = "",
709580
version: str = "",
710581
checksum: Optional[str] = None,
711-
checkfunc: Optional[Callable[[str], Optional[str]]] = None,
712-
checkurl: Optional[str] = None,
713582
) -> None:
714583
self.name = name
715584
self.url_tpl = url
@@ -720,8 +589,6 @@ def __init__(
720589
self._destination = pathlib.Path(destination)
721590
self.version = version
722591
self.checksum = checksum
723-
self.checkfunc = checkfunc
724-
self.checkurl = checkurl
725592

726593
def copy(self) -> "Download":
727594
return Download(
@@ -732,8 +599,6 @@ def copy(self) -> "Download":
732599
self.destination,
733600
self.version,
734601
self.checksum,
735-
self.checkfunc,
736-
self.checkurl,
737602
)
738603

739604
@property
@@ -902,16 +767,6 @@ def __call__(
902767
sys.exit(1)
903768
return valid
904769

905-
def check_version(self) -> bool:
906-
if self.checkfunc is None:
907-
return True
908-
if self.checkurl:
909-
url = self.checkurl
910-
else:
911-
url = self.url.rsplit("/", 1)[0]
912-
check_files(self.name, url, self.checkfunc, self.version)
913-
return True
914-
915770

916771
class Recipe(TypedDict):
917772
"""Typed description of a build recipe entry."""
@@ -1567,16 +1422,6 @@ def __call__(
15671422
if stream_handler is not None:
15681423
log.removeHandler(stream_handler)
15691424

1570-
def check_versions(self) -> bool:
1571-
success = True
1572-
for step in list(self.recipies):
1573-
download = self.recipies[step]["download"]
1574-
if not download:
1575-
continue
1576-
if not download.check_version():
1577-
success = False
1578-
return success
1579-
15801425

15811426
class Builds:
15821427
"""Collection of platform-specific builders."""

0 commit comments

Comments
 (0)