Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions relenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Copyright 2025 Broadcom.
# SPDX-License-Identifier: Apache-2
from __future__ import annotations

import sys

from relenv.common import __version__

MIN_SUPPORTED_PYTHON = (3, 10)

if sys.version_info < MIN_SUPPORTED_PYTHON:
raise RuntimeError("Relenv requires Python 3.10 or newer.")


__all__ = ["__version__"]
14 changes: 10 additions & 4 deletions relenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
The entrypoint into relenv.
"""

from __future__ import annotations

import argparse
from argparse import ArgumentParser
from types import ModuleType

from . import build, buildenv, check, create, fetch, pyversions, toolchain
from .common import __version__


def setup_cli():
def setup_cli() -> ArgumentParser:
"""
Build the argparser with its subparsers.

Expand All @@ -25,9 +29,11 @@ def setup_cli():
description="Relenv",
)
argparser.add_argument("--version", action="version", version=__version__)
subparsers = argparser.add_subparsers()
subparsers: argparse._SubParsersAction[
argparse.ArgumentParser
] = argparser.add_subparsers()

modules_to_setup = [
modules_to_setup: list[ModuleType] = [
build,
toolchain,
create,
Expand All @@ -42,7 +48,7 @@ def setup_cli():
return argparser


def main():
def main() -> None:
"""
Run the relenv cli and disbatch to subcommands.
"""
Expand Down
27 changes: 16 additions & 11 deletions relenv/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
"""
The ``relenv build`` command.
"""
import sys
import random
from __future__ import annotations

import argparse
import codecs
import random
import signal
import sys
from types import ModuleType

from . import linux, darwin, windows
from .common import builds, CHECK_VERSIONS_SUPPORT

from ..pyversions import python_versions, Version

from ..common import build_arch, DEFAULT_PYTHON
from . import darwin, linux, windows
from .common import CHECK_VERSIONS_SUPPORT, builds
from ..common import DEFAULT_PYTHON, build_arch
from ..pyversions import Version, python_versions


def platform_module():
def platform_module() -> ModuleType:
"""
Return the right module based on `sys.platform`.
"""
Expand All @@ -26,9 +28,12 @@ def platform_module():
return linux
elif sys.platform == "win32":
return windows
raise RuntimeError(f"Unsupported platform: {sys.platform}")


def setup_parser(subparsers):
def setup_parser(
subparsers: argparse._SubParsersAction[argparse.ArgumentParser],
) -> None:
"""
Setup the subparser for the ``build`` command.
Expand Down Expand Up @@ -124,7 +129,7 @@ def setup_parser(subparsers):
)


def main(args):
def main(args: argparse.Namespace) -> None:
"""
The entrypoint to the ``build`` command.
Expand Down
Loading
Loading