Skip to content

Commit

Permalink
Merge pull request kubeedge#184 from JoeyHwong-gk/common
Browse files Browse the repository at this point in the history
Fix install issues about lib
  • Loading branch information
kubeedge-bot authored Oct 13, 2021
2 parents 1d7bd48 + 14b22ec commit 1c5c537
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include OWNERS requirements.txt sedna/VERSION README.md
include OWNERS requirements.txt requirements.dev.txt sedna/VERSION sedna/README.md
recursive-include examples *.txt *.py
4 changes: 4 additions & 0 deletions lib/requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# federated_learning
plato-learn~=0.26 # Apache-2.0
# lifelong_learning
scikit-learn~=0.24.1 # BSD
7 changes: 3 additions & 4 deletions lib/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
numpy>=1.13.3 # BSD
colorlog~=4.7.2 # MIT
websockets~=9.1 # BSD
requests==2.24.0 # Apache-2.0
requests>=2.24.0 # Apache-2.0
PyYAML~=5.4.1 # MIT
setuptools~=54.2.0
fastapi~=0.68.1 # MIT
starlette~=0.14.2 # BSD
pydantic~=1.8.1 # MIT
pydantic>=1.8.1 # MIT
tenacity~=8.0.1 # Apache-2.0
joblib~=1.0.1 # BSD
pandas~=1.1.5 # BSD
six~=1.15.0 # MIT
minio~=7.0.3 # Apache-2.0
uvicorn~=0.14.0 # BSD
uvicorn>=0.14.0 # BSD
4 changes: 4 additions & 0 deletions lib/sedna/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pip install dist/sedna*.whl
Install via Setuptools

```bash
# Install dependence
pip install -r requirements.txt

# Install sedna
python setup.py install --user
```

Expand Down
8 changes: 7 additions & 1 deletion lib/sedna/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
# limitations under the License.

"""sedna version information."""
import os

__version__ = '0.3.1'

_VERSION = os.path.join(os.path.dirname(__file__), "VERSION")

with open(_VERSION, "r", encoding="utf-8") as fin:
tmp = [line.strip() for line in fin if line.strip()]
__version__ = "-".join(tmp) if tmp else "dev"
1 change: 0 additions & 1 deletion lib/sedna/service/server/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import contextlib
import time
import threading
import asyncio

import uvicorn
from fastapi.middleware.cors import CORSMiddleware
Expand Down
110 changes: 91 additions & 19 deletions lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,105 @@

assert sys.version_info >= (3, 6), "Sorry, Python < 3.6 is not supported."

with open("README.md", "r") as fh:
long_desc = fh.read()

with open(os.path.join(os.path.dirname(__file__), 'sedna', 'VERSION'),
"r", encoding="utf-8") as fh:
__version__ = fh.read().strip()
class InstallPrepare:
"""
Parsing dependencies
"""

with open("requirements.txt", "r", encoding="utf-8") as fh:
install_requires = [line.strip() for line in
fh.readlines() if line.strip()]
def __init__(self):
self.project = os.path.join(os.path.dirname(__file__), "sedna")
self._long_desc = os.path.join(self.project, "README.md")
self._version = os.path.join(self.project, "VERSION")
self._owner = os.path.join(self.project, "..", "OWNERS")
self._requirements = os.path.join(self.project, "..",
"requirements.txt")
self._dev_requirements = os.path.join(self.project, "..",
"requirements.dev.txt")

@property
def long_desc(self):
if not os.path.isfile(self._long_desc):
return ""
with open(self._long_desc, "r", encoding="utf-8") as fh:
long_desc = fh.read()
return long_desc

@property
def version(self):
default_version = "999.dev"
if not os.path.isfile(self._version):
return default_version
with open(self._version, "r", encoding="utf-8") as fh:
__version__ = fh.read().strip()
return __version__ or default_version

@property
def owners(self):
default_owner = "sedna"
if not os.path.isfile(self._owner):
return default_owner
with open(self._owner, "r", encoding="utf-8") as fh:
check, approvers = False, set()
for line in fh:
if not line.strip():
continue
if check:
approvers.add(line.strip().split()[-1])
check = (line.startswith("approvers:") or
(line.startswith(" -") and check))
return ",".join(approvers) or default_owner

@property
def basic_dependencies(self):
return self._read_requirements(self._requirements)

def feature_dependencies(self, feature):
_c = os.path.join(self.project, 'core', feature, "requirements.txt")
if os.path.isfile(_c):
return self._read_requirements(_c)
return self._read_requirements(self._dev_requirements, feature)

@staticmethod
def _read_requirements(file_path, section="all"):
print(f"Start to install requirements of {section} "
f"in sedna from {file_path}")
if not os.path.isfile(file_path):
return []
with open(file_path, "r", encoding="utf-8") as f:
install_requires = [p.strip() for p in f.readlines() if p.strip()]
if section == "all":
return list(filter(lambda x: not x.startswith("#"),
install_requires))
section_start = False
section_requires = []
for p in install_requires:
if section_start:
if p.startswith("#"):
return section_requires
section_requires.append(p)
elif p.startswith(f"# {section}"):
section_start = True
return section_requires


_infos = InstallPrepare()

setup(
name='sedna',
version=__version__,
version=_infos.version,
description="The sedna package is designed to help developers \
better use open source frameworks such as tensorflow \
on Sedna project",
packages=find_packages(exclude=["tests", "*.tests",
"*.tests.*", "tests.*"]),
author="",
author_email="",
maintainer="",
author=_infos.owners,
author_email="pujie2@huawei.com",
maintainer=_infos.owners,
maintainer_email="",
include_package_data=True,
python_requires=">=3.6",
long_description=long_desc,
long_description=_infos.long_desc,
long_description_content_type="text/markdown",
license="Apache License 2.0",
url="https://github.com/kubeedge/sedna",
Expand All @@ -53,12 +126,11 @@
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
],
install_requires=install_requires,
install_requires=_infos.basic_dependencies,
extras_require={
"tf": ["tensorflow>=1.0.0,<2.0"],
"tf_gpu": ["tensorflow-gpu>=1.0.0,<2.0"],
"pytorch": ["torch==0.4.0", "torchvision==0.2.1"],
"ms": ["mindspore==1.1.1"],
"sklearn": ["pandas>=0.25.0", "scikit-learn==0.24.1"]
"fl": _infos.feature_dependencies("federated_learning"),
"il": _infos.feature_dependencies("incremental_learning"),
"ji": _infos.feature_dependencies("joint_inference"),
"ll": _infos.feature_dependencies("lifelong_learning")
},
)

0 comments on commit 1c5c537

Please sign in to comment.