This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
executable file
·171 lines (114 loc) · 4.92 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__copyright__ = "Copyright (C) 2014 Ivan D Vasin"
__credits__ = ["Ivan D Vasin"]
__maintainer__ = "Ivan D Vasin"
__email__ = "[email protected]"
__docformat__ = "restructuredtext"
import io as _io
import os as _os
import re as _re
from setuptools import find_packages as _find_packages, setup as _setup
# helpers ---------------------------------------------------------------------
MOD_DOC_RE = _re.compile(r'\A(?:(?:\s*(?:\#[^$]*)\n)$)*'
r'(?:(?P<dquot>""")|(?P<squot>\'\'\'))\n?'
r'(?P<doc>.*)'
r'(?(dquot)"""|\'\'\')',
_re.DOTALL | _re.MULTILINE)
MOD_VERSION_RE = _re.compile(r'^__version__ = [\'"](?P<version>[^\'"]*)[\'"]$',
_re.MULTILINE)
def file_abspath_from_parts(*relpath_parts):
return _os.path.join(_os.path.abspath(_os.path.dirname(__file__)),
*relpath_parts)
def shortdoc_from_doc(doc):
def iter_shortdoc_lines():
for line in doc.split(_os.linesep):
if not line.strip():
return
if line[-1] in '.?!':
line += ' '
yield line
return ' '.join(iter_shortdoc_lines())
def read_doc(mod_filepath):
mod_text = _io.open(mod_filepath).read()
match = MOD_DOC_RE.search(mod_text)
if not match:
raise RuntimeError('cannot find module docstring in file {!r} with'
' pattern {!r}'
.format(mod_filepath, MOD_DOC_RE.pattern))
return match.group('doc')
def read_version(mod_filepath):
mod_text = _io.open(mod_filepath).read()
mod_version_match = MOD_VERSION_RE.search(mod_text)
if not mod_version_match:
raise RuntimeError('cannot find module version string in file {!r}'
' with pattern {!r}'
.format(mod_filepath, MOD_VERSION_RE.pattern))
return mod_version_match.group('version')
# basics ----------------------------------------------------------------------
NAME = 'GooseTypes'
ROOT_PKG_NAME = _re.sub(r'[^\d\w]', '_', _re.sub(r'^[^\w]', '_', NAME.lower()))
ROOT_PKG_ABSPATH = file_abspath_from_parts(*(ROOT_PKG_NAME.split('.')
+ ['__init__.py']))
VERSION = read_version(ROOT_PKG_ABSPATH)
SITE_URI = ''
DOWNLOAD_URI = 'https://github.com/nisavid/goosetypes'
DESCRIPTION = shortdoc_from_doc(read_doc(ROOT_PKG_ABSPATH))
README_FILE = 'README.rst'
README = _io.open(README_FILE, 'r').read()
CHANGES_FILE = 'CHANGES.rst'
CHANGES = _io.open(CHANGES_FILE, 'r').read()
LICENSE_FILE = 'LICENSE'
LICENSE = _io.open(LICENSE_FILE, 'r').read()
LONG_DESCRIPTION = '\n\n'.join((README, CHANGES))
TROVE_CLASSIFIERS = \
('Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3'
' (LGPLv3)',
'Operating System :: POSIX',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Libraries :: Python Modules',
)
# dependencies ----------------------------------------------------------------
SETUP_DEPS = ()
INSTALL_DEPS = ('spruce-types',)
EXTRAS_DEPS = {}
TESTS_DEPS = ()
DEPS_SEARCH_URIS = ()
# packages --------------------------------------------------------------------
NAMESPACE_PKGS_PATHS = ()
SCRIPTS_PKG_NAME = '.'.join((ROOT_PKG_NAME, 'scripts'))
TESTS_PKG_NAME = '.'.join((ROOT_PKG_NAME, 'tests'))
# entry points ----------------------------------------------------------------
STD_SCRIPTS_PKG_COMMANDS = {}
COMMANDS = {cmd: '{}.{}:{}'.format(SCRIPTS_PKG_NAME,
script if isinstance(script, basestring)
else script[0],
'main' if isinstance(script, basestring)
else script[1])
for cmd, script in STD_SCRIPTS_PKG_COMMANDS.items()}
ENTRY_POINTS = {'console_scripts': ['{} = {}'.format(name, funcpath)
for name, funcpath in COMMANDS.items()]}
if __name__ == '__main__':
_setup(name=NAME,
version=VERSION,
url=SITE_URI,
download_url=DOWNLOAD_URI,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
author=', '.join(__credits__),
maintainer=__maintainer__,
maintainer_email=__email__,
license=LICENSE,
classifiers=TROVE_CLASSIFIERS,
setup_requires=SETUP_DEPS,
install_requires=INSTALL_DEPS,
extras_require=EXTRAS_DEPS,
tests_require=TESTS_DEPS,
dependency_links=DEPS_SEARCH_URIS,
namespace_packages=NAMESPACE_PKGS_PATHS,
packages=_find_packages(),
test_suite=TESTS_PKG_NAME,
include_package_data=True,
entry_points=ENTRY_POINTS)