-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathsetup.py
More file actions
152 lines (132 loc) · 4.42 KB
/
setup.py
File metadata and controls
152 lines (132 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright 2022 The FeatHub Authors
#
# 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
#
# https://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 os
import sys
from datetime import datetime
from shutil import rmtree, copytree
from setuptools import setup, find_packages
def remove_if_exists(file_path):
if os.path.exists(file_path):
if os.path.islink(file_path) or os.path.isfile(file_path):
os.remove(file_path)
else:
assert os.path.isdir(file_path)
rmtree(file_path)
# clear setup cache directories
remove_if_exists("build")
this_directory = os.path.abspath(os.path.dirname(__file__))
nightly_build = os.getenv("NIGHTLY_BUILD") == "true"
version_file = os.path.join(this_directory, "feathub/version.py")
try:
exec(open(version_file).read())
except IOError:
print(
"Failed to load FeatHub version file for packaging. "
+ "'%s' not found!" % version_file,
file=sys.stderr,
)
sys.exit(-1)
PACKAGE_NAME = "feathub"
VERSION = __version__ # noqa
TEMP_PATH = "deps"
TEMP_FLINK_PROCESSOR_LIB_DIR = os.path.join(TEMP_PATH, "processors", "flink", "lib")
feathub_version = VERSION.replace(".dev0", "-SNAPSHOT")
FEATHUB_FLINK_PROCESSOR_LIB_DIR = os.path.join(
this_directory,
"..",
"java",
"feathub-dist",
"target",
f"feathub-dist-{feathub_version}-bin",
f"feathub-dist-{feathub_version}",
"lib",
)
in_feathub_source = os.path.isfile("../java/feathub-dist/pom.xml")
if nightly_build:
if "dev" not in VERSION:
raise RuntimeError("Nightly wheel is not supported for non dev version")
VERSION = VERSION[: str.find(VERSION, "dev") + 3] + datetime.now().strftime(
"%Y%m%d"
)
PACKAGE_NAME = f"{PACKAGE_NAME}_nightly"
try:
if in_feathub_source:
try:
os.mkdir(TEMP_PATH)
except:
print(
"Temp path for symlink to parent already exists {0}".format(TEMP_PATH),
file=sys.stderr,
)
sys.exit(-1)
try:
os.symlink(FEATHUB_FLINK_PROCESSOR_LIB_DIR, TEMP_FLINK_PROCESSOR_LIB_DIR)
except BaseException: # pylint: disable=broad-except
copytree(FEATHUB_FLINK_PROCESSOR_LIB_DIR, TEMP_FLINK_PROCESSOR_LIB_DIR)
PACKAGES = find_packages(include=["feathub", "feathub.*"], exclude=["*tests*"])
PACKAGES.append("feathub.processors.flink.lib")
PACKAGE_DIR = {
"feathub.processors.flink.lib": TEMP_FLINK_PROCESSOR_LIB_DIR,
}
PACKAGE_DATA = {
"feathub.processors.flink.lib": ["*.jar"],
"feathub.examples": ["*.csv"],
}
install_requires = [
"scikit-learn",
"ply>=3.11",
"pandas>=1.1.5,<2.0",
"numpy~=1.21.4",
"kubernetes~=24.2",
"python-dateutil~=2.8",
"redis==4.3.0",
"tzlocal~=4.2",
"mysql-connector-python~=8.0.0",
"cloudpickle==2.1.0",
]
extras_require = {
"flink": [
"apache-flink==1.16.1",
],
"spark": [
"pyspark==3.3.1",
],
}
setup(
name=PACKAGE_NAME,
version=VERSION,
description="A stream-batch unified feature store for real-time machine "
"learning",
url="https://github.com/alibaba/feathub",
packages=PACKAGES,
include_package_data=True,
package_dir=PACKAGE_DIR,
package_data=PACKAGE_DATA,
license="https://www.apache.org/licenses/LICENSE-2.0",
author="FeatHub Authors",
python_requires=">=3.7",
install_requires=install_requires,
extras_require=extras_require,
tests_require=["pytest==4.4.1"],
zip_safe=True,
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)
finally:
if in_feathub_source:
remove_if_exists(TEMP_PATH)