-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsetup.py
181 lines (128 loc) · 4.74 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
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python
# Copyright 2009-2017 Ram Rachum.
# This program is distributed under the MIT license.
'''Setuptools setup file for `python_toolbox`.'''
import os
import re
import setuptools
import sys
def read_file(filename):
with open(filename) as file:
return file.read()
version = re.search("__version__ = '([0-9.]*)'",
read_file('python_toolbox/__init__.py')).group(1)
def get_python_toolbox_packages():
'''
Get all the packages in `python_toolbox`.
Returns something like:
['python_toolbox', 'python_toolbox.caching',
'python_toolbox.nifty_collections', ... ]
'''
return ['python_toolbox.' + p for p in
setuptools.find_packages('python_toolbox')] + \
['python_toolbox']
def get_test_python_toolbox_packages():
'''
Get all the packages in `test_python_toolbox`.
Returns something like:
['test_python_toolbox', 'test_python_toolbox.test_caching',
'test_python_toolbox.test_nifty_collections', ... ]
'''
return ['test_python_toolbox.' + p for p in
setuptools.find_packages('test_python_toolbox')] + \
['test_python_toolbox']
def get_packages():
'''
Get all the packages in `python_toolbox` and `test_python_toolbox`.
Returns something like:
['test_python_toolbox', 'python_toolbox', 'python_toolbox.caching',
'test_python_toolbox.test_nifty_collections', ... ]
'''
return get_python_toolbox_packages() + get_test_python_toolbox_packages()
my_long_description = \
'''\
The Python Toolbox is a collection of Python tools for various tasks. It
contains:
- ``python_toolbox.caching``: Tools for caching functions, class instances and
properties.
- ``python_toolbox.cute_iter_tools``: Tools for manipulating iterables. Adds
useful functions not found in Python's built-in ``itertools``.
- ``python_toolbox.context_management``: Pimping up your context managers.
- ``python_toolbox.emitting``: A publisher-subscriber framework that doesn't
abuse strings.
- And many, *many* more! The Python Toolbox contains **100+** useful
little tools.
Documentation: http://python-toolbox.readthedocs.io
Python Toolbox on GitHub: https://github.com/cool-RR/python_toolbox
Python Toolbox on PyPI: https://pypi.python.org/pypi/python_toolbox
Tests
=====
Test can be run by running the ``_test_python_toolbox.py`` script that's
installed automatically with the Python Toolbox.
When ``python_toolbox`` isn't installed, you may run ``pytest`` at the repo
root to run the tests.
-------------------------------------------------------
The Python Toolbox was created by Ram Rachum. I provide
`Development services in Python and Django <https://chipmunkdev.com>`_.
'''
my_classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities'
]
install_requires = ['setuptools']
try:
from setuptools.command.test import test as TestCommand
except ImportError:
# This setuptools is deprecated so it may be removed in the future.
PyTest = None
else:
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
setuptools.setup(
name='python_toolbox',
version=version,
install_requires=install_requires,
description='A collection of Python tools for various tasks',
author='Ram Rachum',
author_email='[email protected]',
package_dir={'': '.'},
packages=get_packages(),
scripts=['test_python_toolbox/scripts/_test_python_toolbox.py'],
entry_points={
'console_scripts': [
'_test_python_toolbox = test_python_toolbox:invoke_tests',
],
},
long_description=my_long_description,
license='MIT',
classifiers=my_classifiers,
include_package_data=True,
zip_safe=False,
extras_require={
'tests': {
'pytest',
'docutils>=0.8',
},
},
cmdclass=({'test': PyTest,} if PyTest is not None else {})
)