-
Notifications
You must be signed in to change notification settings - Fork 40
/
setup.py
75 lines (55 loc) · 2.1 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
import setuptools
import os
from setuptools import find_packages
from setuptools.command.build_py import build_py as build_py_orig
def generate_man1_pages(share_path, docs):
data_files = []
for path, _, files in os.walk(docs):
list_entry = (share_path, [os.path.join(path, f) for f in files if f.endswith(".1")])
data_files.append(list_entry)
return data_files
def generate_man5_pages(share_path, docs):
data_files = []
for path, _, files in os.walk(docs):
list_entry = (share_path, [os.path.join(path, f) for f in files if f.endswith(".5")])
data_files.append(list_entry)
return data_files
def generate_ramalama_conf(share_path, docs):
data_files = []
for path, _, files in os.walk(docs):
list_entry = (share_path, [os.path.join(path, f) for f in files if f.endswith(".conf")])
data_files.append(list_entry)
return data_files
def generate_completions(share_path, completions):
data_files = []
def remove_prefix(s, prefix):
if s.startswith(prefix):
length = len(prefix) + 1
return s[length:]
else:
return s
for path, _, files in os.walk(completions):
if len(files) == 0:
continue
list_entry = (
os.path.join(share_path, remove_prefix(path, completions)),
[os.path.join(path, f) for f in files],
)
data_files.append(list_entry)
return data_files
class build_py(build_py_orig):
def find_package_modules(self, package, package_dir):
modules = super().find_package_modules(package, package_dir)
return [(pkg, mod, file) for (pkg, mod, file) in modules]
setuptools.setup(
name="ramalama",
version="0.0.22",
packages=find_packages(),
cmdclass={"build_py": build_py},
scripts=["bin/ramalama"],
data_files=[("share/ramalama", ["shortnames/shortnames.conf"])]
+ generate_completions("share", "completions")
+ generate_ramalama_conf("share/ramalama", "docs")
+ generate_man1_pages("share/man/man1", "docs")
+ generate_man5_pages("share/man/man5", "docs"),
)