-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
57 lines (45 loc) · 1.38 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
""" Setup script for the logparser application.
"""
from os import walk
from pathlib import Path
from setuptools import find_packages
from setuptools import setup
_config = {
"name": "logparser",
"url": "",
"author": "alex",
"author_email": "amakasoff@arlo.com",
"package_dir": {"": "src"},
"packages": find_packages("src"),
"entry_points": {
"console_scripts": ("logparser = logparser.cli:main",),
},
"data_files": ("etc/",),
}
def main() -> int:
""" Execute the setup command.
"""
def data_files(*paths):
""" Expand path contents for the `data_files` config variable. """
for path in map(Path, paths):
if path.is_dir():
for root, _, files in walk(str(path)):
yield root, tuple(str(Path(root, name)) for name in files)
else:
yield str(path.parent), (str(path),)
return
def version():
""" Get the local package version. """
namespace = {}
path = Path("src", _config["name"], "__version__.py")
exec(path.read_text(), namespace)
return namespace["__version__"]
_config.update({
"data_files": list(data_files(*_config["data_files"])),
"version": version(),
})
setup(**_config)
return 0
# Make the script executable.
if __name__ == "__main__":
raise SystemExit(main())