From 46bfe444964cb781dde64e5704da028cdaa25292 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Mon, 6 Nov 2023 22:05:50 +0900 Subject: [PATCH] feat: Add skeleton for the "installer" package --- src/ai/backend/install/BUILD | 61 ++++++++++++++++++++++++++++++ src/ai/backend/install/README.md | 7 ++++ src/ai/backend/install/VERSION | 1 + src/ai/backend/install/__init__.py | 3 ++ src/ai/backend/install/cli.py | 26 +++++++++++++ src/ai/backend/install/py.typed | 0 src/ai/backend/install/types.py | 6 +++ 7 files changed, 104 insertions(+) create mode 100644 src/ai/backend/install/BUILD create mode 100644 src/ai/backend/install/README.md create mode 120000 src/ai/backend/install/VERSION create mode 100644 src/ai/backend/install/__init__.py create mode 100644 src/ai/backend/install/cli.py create mode 100644 src/ai/backend/install/py.typed create mode 100644 src/ai/backend/install/types.py diff --git a/src/ai/backend/install/BUILD b/src/ai/backend/install/BUILD new file mode 100644 index 0000000000..1e36cfbac3 --- /dev/null +++ b/src/ai/backend/install/BUILD @@ -0,0 +1,61 @@ +python_sources( + name="src", + dependencies=[ + ":resources", + ], +) + +visibility_private_component( + allowed_dependents=[], + allowed_dependencies=[ + "//src/ai/backend/cli/**", + "//src/ai/backend/common/**", + ] +) + +python_distribution( + name="dist", + dependencies=[ + ":src", + "!!stubs/trafaret:stubs", + ], + provides=python_artifact( + name="backend.ai-install", + description="Backend.AI Installer", + license="MIT", + ), + entry_points={ + "backendai_cli_v10": { + "install": "ai.backend.install.cli:main", + }, + }, + generate_setup=True, + tags=["wheel"], +) + +pex_binary( + name="pex", + entry_point="ai.backend.cli.__main__", + dependencies=[ + ":src", + ":buildscript", + "!!stubs/trafaret:stubs", + ], +) + +scie_binary( + name="backendai-install", + dependencies=[":pex"], +) + +resource(name="version", source="VERSION") +resource(name="buildscript", source="BUILD") +resources( + name="resources", + dependencies=[ + ":version", + ], + sources=[ + "**/py.typed", + ], +) diff --git a/src/ai/backend/install/README.md b/src/ai/backend/install/README.md new file mode 100644 index 0000000000..cc57c434be --- /dev/null +++ b/src/ai/backend/install/README.md @@ -0,0 +1,7 @@ +Backend.AI Plugin Subsystem +=========================== + +Package Structure +----------------- + +* `ai.backend.plugin`: Abstract types for plugins and a common base plugin set diff --git a/src/ai/backend/install/VERSION b/src/ai/backend/install/VERSION new file mode 120000 index 0000000000..a4e948506b --- /dev/null +++ b/src/ai/backend/install/VERSION @@ -0,0 +1 @@ +../../../../VERSION \ No newline at end of file diff --git a/src/ai/backend/install/__init__.py b/src/ai/backend/install/__init__.py new file mode 100644 index 0000000000..67adea593b --- /dev/null +++ b/src/ai/backend/install/__init__.py @@ -0,0 +1,3 @@ +from pathlib import Path + +__version__ = (Path(__file__).parent / "VERSION").read_text().strip() diff --git a/src/ai/backend/install/cli.py b/src/ai/backend/install/cli.py new file mode 100644 index 0000000000..85ec814936 --- /dev/null +++ b/src/ai/backend/install/cli.py @@ -0,0 +1,26 @@ +import click + +from ai.backend.install import __version__ + +from .types import InstallModes + + +@click.command( + context_settings={ + "help_option_names": ["-h", "--help"], + }, +) +@click.option( + "--mode", + type=click.Choice(InstallModes._member_names_, case_sensitive=False), + default=None, + help="Override the installation mode. [default: auto-detect]", +) +@click.version_option(version=__version__) +@click.pass_context +def main( + ctx: click.Context, + mode: InstallModes | None, +) -> None: + """The installer""" + print(f"installer main: {mode}") diff --git a/src/ai/backend/install/py.typed b/src/ai/backend/install/py.typed new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/ai/backend/install/types.py b/src/ai/backend/install/types.py new file mode 100644 index 0000000000..751c1fba7a --- /dev/null +++ b/src/ai/backend/install/types.py @@ -0,0 +1,6 @@ +import enum + + +class InstallModes(enum.StrEnum): + DEV = "dev" + PACKAGE = "pkg"