From c7d75927b0408f796abe11d48a9228142e71f218 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 2 Oct 2024 14:11:29 -0700 Subject: [PATCH] Draft a shark-platform meta package to organize Python packages. --- pyproject.toml | 6 ++++ setup.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..714f4804e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=61.0", + "wheel", +] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..e57420352 --- /dev/null +++ b/setup.py @@ -0,0 +1,84 @@ +# Copyright 2024 Advanced Micro Devices, Inc. +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import json +import os +import distutils.command.build +from pathlib import Path + +from setuptools import setup # type: ignore + +THIS_DIR = Path(__file__).resolve().parent +REPO_DIR = THIS_DIR +VERSION_INFO_FILE = REPO_DIR / "version_info.json" + + +def load_version_info(): + with open(VERSION_INFO_FILE, "rt") as f: + return json.load(f) + + +version_info = load_version_info() +PACKAGE_VERSION = version_info["package-version"] + +with open(os.path.join(THIS_DIR, "README.md"), "rt") as f: + README = f.read() + + +# Override build command so that we can build into _python_build +# instead of the default "build". This avoids collisions with +# typical CMake incantations, which can produce all kinds of +# hilarity (like including the contents of the build/lib directory). +class BuildCommand(distutils.command.build.build): + def initialize_options(self): + distutils.command.build.build.initialize_options(self) + self.build_base = "_python_build" + + +setup( + name=f"shark-platform", + version=f"{PACKAGE_VERSION}", + author="SHARK Authors", + description="SHARK Platform meta package", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/nod-ai/SHARK-Platform", + license="Apache-2.0", + classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ], + packages=[], + install_requires=[ + # "sharktank", + "shortfin", + ], + extras_require={ + "apps": [ + # TODO: add others here, or just rely on what sharktank depends on? + # e.g. transformers, huggingface-hub + "dataclasses-json", + "tokenizers", + ], + "onnx": [ + "iree-runtime", + "iree-compiler[onnx]", + ], + "torch": [ + # TODO: plumb through [cpu,cuda,rocm] extras (if possible) + # PyTorch uses `--index-url https://download.pytorch.org/whl/cpu`, + # see https://pytorch.org/get-started/locally/. + # TODO: or just drop this? if sharktank always pulls it in + "iree-turbine", + ], + "serving": [ + "fastapi", + "uvicorn", + ], + }, + cmdclass={"build": BuildCommand}, +)