-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·136 lines (119 loc) · 2.97 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python3
"""
"""
import os
import sys
from setuptools import setup, find_packages
assert sys.version_info >= (3, 7), \
f"Python >= 3.7 required, have {sys.version}"
PT_EXCLUDE_LIBS = os.environ.get('PT_EXCLUDE_LIBS', '').strip()
EXCLUDE_LIBS = set(
x.strip()
for x in PT_EXCLUDE_LIBS.split(',')
)
print(EXCLUDE_LIBS)
def load_requirements(*fnames):
if PT_EXCLUDE_LIBS == 'ALL':
return []
result = []
for fname in fnames:
with open(fname) as f:
reqs = [
x.strip() for x in f
if (
x.strip()
and
not x.strip().startswith('#')
)
]
result.extend([
x for x in reqs
if x not in EXCLUDE_LIBS
])
print(result)
return result
NAME = "pytemplate"
URL = 'https://github.com/d3v-t00Lz/python-template' # TODO
DESCRIPTION = (
"TODO"
)
CWD = os.path.abspath(
os.path.dirname(__file__),
)
SCRIPTS_DIR = os.path.join(CWD, 'scripts')
SCRIPTS = [
os.path.join('scripts', x)
for x in os.listdir(SCRIPTS_DIR)
] if os.path.isdir(SCRIPTS_DIR) else []
def _version():
path = sys.path[:]
dirname = os.path.dirname(__file__)
abspath = os.path.join(
os.path.abspath(dirname),
'src',
)
sys.path.insert(
0,
abspath,
)
import pytemplate
version = pytemplate.__version__
sys.path = path
return version
VERSION = _version()
def _gitlab_download_url(
name=NAME,
url=URL,
version=VERSION,
):
return f"{url}/-/archive/{version}/{name}-{version}.tar.gz"
def _github_download_url(
url=URL,
version=VERSION,
):
return f"{url}/archive/{version}.tar.gz"
def package_data(*paths):
result = []
for path in paths:
for (root, dirs, fnames) in os.walk(path):
for fname in fnames:
if os.path.basename(fname) == '__init__.py':
continue
result.append(
os.path.join(CWD, root, fname)
)
for fname in result:
assert os.path.isfile(fname), fname
return result
with open('README.md', 'rt') as f:
LONG_DESC = f.read()
setup(
name=NAME,
version=VERSION,
author="TODO",
author_email="TODO",
description=DESCRIPTION,
include_package_data=True,
package_data={
'pytemplate': package_data('src/pytemplate/files'),
},
long_description=LONG_DESC,
long_description_content_type='text/markdown',
url=URL,
packages=find_packages(where='src'),
package_dir = {'': 'src'},
install_requires=load_requirements(
*(
os.path.join('requirements', x)
for x in os.listdir('requirements')
if x not in ('test.txt', 'devel.txt')
)
),
extras_require={},
scripts=SCRIPTS,
# PT:PYPI
# PyPI
download_url=_gitlab_download_url(), # TODO
keywords=[], # TODO
# PT:PYPI
)