-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
109 lines (96 loc) · 4.02 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- coding: utf-8 -*-
"""
setup.py implementation, interesting because it parsed the first __init__.py and
extracts the `__author__` and `__version__`
"""
from ast import parse
from distutils.sysconfig import get_python_lib
from functools import partial
from operator import attrgetter, itemgetter
from os import listdir, path
from sys import version_info
from setuptools import find_packages, setup
if version_info[0] == 2:
from itertools import ifilter as filter
from itertools import imap as map
package_name = "nginxctl"
def to_funcs(*paths):
"""
Produce function tuples that produce the local and install dir, respectively.
:param paths: one or more str, referring to relative folder names
:type paths: ```*paths```
:returns: 2 functions
:rtype: ```Tuple[Callable[Optional[List[str]], str], Callable[Optional[List[str]], str]]```
"""
return (
partial(path.join, path.dirname(__file__), package_name, *paths),
partial(path.join, get_python_lib(prefix=""), package_name, *paths),
)
if __name__ == "__main__":
with open(path.join(package_name, "__init__.py")) as f:
__author__, __version__ = map(
lambda const: const.value if hasattr(const, "value") else const.s,
map(
attrgetter("value"),
map(
itemgetter(0),
map(
attrgetter("body"),
map(
parse,
filter(
lambda line: line.startswith("__version__")
or line.startswith("__author__"),
f,
),
),
),
),
),
)
_data_join, _data_install_dir = to_funcs("_data")
_config_join, _config_install_dir = to_funcs("_config")
setup(
name=package_name,
author=__author__,
version=__version__,
install_requires=["crossplane", "boltons", "meta", "pyyaml!=6.0.0,!=5.4.0,!=5.4.1"],
test_suite=package_name + ".tests",
packages=find_packages(),
package_dir={package_name: package_name},
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: Implementation",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Internet :: Proxy Servers"
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Pre-processors",
"Topic :: Software Development",
],
data_files=[
(_data_install_dir(), list(map(_data_join, listdir(_data_join())))),
(_config_install_dir(), list(map(_config_join, listdir(_config_join())))),
],
)