-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsetup.py
68 lines (54 loc) · 1.57 KB
/
setup.py
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
import sys
from pathlib import Path
from shutil import copytree
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
from dps.spark_df import VERSION
PKGNAME = "dps"
PYTHON_MIN_VERSION = (3, 8)
if sys.version_info < PYTHON_MIN_VERSION:
sys.exit(
"**** Sorry, {} {} needs at least Python {}".format(
PKGNAME, VERSION, ".".join(map(str, PYTHON_MIN_VERSION))
)
)
def post_install_hook():
'''
Execute post-install tasks
'''
src_dir = Path(__file__).parent / "configs"
dst_dir = Path(sys.prefix) / "etc" / "dps"
try:
copytree(src_dir, dst_dir, dirs_exist_ok=True)
except Exception as e:
print(repr(e), file=sys.stderr, flush=True)
raise
class PostInstall(install):
def run(self):
super().run()
post_install_hook()
class PostDevelop(develop):
def run(self):
super().run()
raise Exception()
post_install_hook()
def requirements(filename="requirements-df.txt"):
"""Read the requirements file"""
with open(filename, "r") as f:
return [line.strip() for line in f if line and line[0] != "#"]
setup(
name=PKGNAME,
version=VERSION,
packages=find_packages("."),
license="Apache",
entry_points={
"console_scripts": [
"dps-run-spark = dps.spark_df.app.sparkapp:main"
]
},
python_requires=">=3.8",
install_requires=requirements(),
cmdclass={'install': PostInstall,
'develop': PostDevelop}
)