Support megaservice ut in CI test (#13)

Signed-off-by: chensuyue <suyue.chen@intel.com>
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
This commit is contained in:
chen, suyue
2024-05-09 13:51:05 +08:00
committed by GitHub
parent b7bce38669
commit bdffd11785
16 changed files with 415 additions and 7 deletions

86
setup.py Normal file
View File

@@ -0,0 +1,86 @@
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re
import subprocess
from io import open
from setuptools import find_packages, setup
def fetch_requirements(path):
with open(path, "r") as fd:
return [r.strip() for r in fd.readlines()]
def is_commit_on_tag():
try:
result = subprocess.run(
["git", "describe", "--exact-match", "--tags"], capture_output=True, text=True, check=True
)
tag_name = result.stdout.strip()
return tag_name
except subprocess.CalledProcessError:
return False
def get_build_version():
if is_commit_on_tag():
return __version__
try:
result = subprocess.run(["git", "describe", "--tags"], capture_output=True, text=True, check=True)
_, distance, commit = result.stdout.strip().split("-")
return f"{__version__}.dev{distance}+{commit}"
except subprocess.CalledProcessError:
return __version__
try:
filepath = "./comps/version.py"
with open(filepath) as version_file:
(__version__,) = re.findall('__version__ = "(.*)"', version_file.read())
except Exception as error:
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)
if __name__ == "__main__":
setup(
name="opea-comps",
author="Intel DCAI Software",
version=get_build_version(),
author_email="liang1.lv@intel.com, haihao.shen@intel.com, suyue.chen@intel.com",
description="Generative AI components",
long_description=open("README.md", "r", encoding="utf-8").read(),
long_description_content_type="text/markdown",
keywords="GenAI",
license="Apache 2.0",
url="https://github.com/opea-project/GenAIComps",
packages=find_packages(
include=[
"comps.cores",
"comps.cores.*",
],
),
package_data={"": ["*.yaml", "../*.py"]},
include_package_data=True,
install_requires=fetch_requirements("requirements.txt"),
python_requires=">=3.8.0",
classifiers=[
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: OSI Approved :: Apache Software License",
],
)