-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
86 lines (68 loc) · 2.12 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import typing
import glob
from pathlib import Path
from setuptools import setup, Command
import logging
import os
name = "pylake"
SOURCES_ROOT = Path(__file__).parent.resolve()
class CleanCommand(Command):
user_options: typing.List[str] = []
def initialize_options(self) -> None:
pass
def finalize_options(self) -> None:
pass
@staticmethod
def rm_all_files(file) -> None:
files = glob.glob(file)
stack = files
files_sorted = []
def rec(stk):
while stk:
f = stk.pop()
fs = glob.glob(f"{f}/*", recursive=True)
for i in fs:
stk.append(i)
rec(stk)
files_sorted.append(f)
return
rec(stack)
for x in files_sorted:
try:
logging.info(f"Removing {x}")
if os.path.isfile(x):
os.remove(x)
else:
os.rmdir(x)
except Exception as e:
logging.warning(f"Error when removing {x}")
logging.exception(e)
def run(self) -> None:
os.chdir(str(SOURCES_ROOT))
self.rm_all_files("./build/*")
self.rm_all_files("./build")
self.rm_all_files("./.pytest_cache/*")
self.rm_all_files("./*.egg-info/*")
self.rm_all_files("./*.egg-info")
self.rm_all_files("./dist/*")
self.rm_all_files("./dist")
self.rm_all_files('./**/__pycache__/*')
self.rm_all_files('./**/*.pyc')
def do_setup():
packages = [x[0].replace("./", "").replace("/", ".") for x in
filter(lambda x: x[2].__contains__("__init__.py"), os.walk("./"))]
version = next(line for line in open("version.txt", "r")).strip()
setup(
name=name,
version=version,
packages=packages,
include_package_data=True,
license="MIT",
author="tuancamtbtx",
description="Python library for Data Engineering",
cmdclass={
'clean': CleanCommand
}
)
if __name__ == '__main__':
do_setup()