1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- encoding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""The setup script.""" |
5
|
|
|
|
6
|
|
|
import io |
7
|
|
|
import os |
8
|
|
|
import platform |
9
|
|
|
import re |
10
|
|
|
from glob import glob |
11
|
|
|
from os.path import basename |
12
|
|
|
from os.path import dirname |
13
|
|
|
from os.path import join |
14
|
|
|
from os.path import relpath |
15
|
|
|
from os.path import splitext |
16
|
|
|
|
17
|
|
|
from setuptools import Extension |
18
|
|
|
from setuptools import find_packages |
19
|
|
|
from setuptools import setup |
20
|
|
|
from setuptools.command.build_ext import build_ext |
21
|
|
|
from setuptools.dist import Distribution |
22
|
|
|
|
23
|
|
|
# Enable code coverage for C code: we can't use CFLAGS=-coverage in tox.ini, since that may mess with compiling |
24
|
|
|
# dependencies (e.g. numpy). Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after |
25
|
|
|
# deps have been safely installed). |
26
|
|
|
if 'TOX_ENV_NAME' in os.environ and os.environ.get('SETUPPY_EXT_COVERAGE') == 'yes' and platform.system() == 'Linux': |
27
|
|
|
CFLAGS = os.environ['CFLAGS'] = '-fprofile-arcs -ftest-coverage' |
28
|
|
|
LFLAGS = os.environ['LFLAGS'] = '-lgcov' |
29
|
|
|
else: |
30
|
|
|
CFLAGS = '' |
31
|
|
|
LFLAGS = '' |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
requirements = ['click', ] |
35
|
|
|
test_requirements = ['pytest>=3', ] |
36
|
|
|
setup_requirements = ['pytest-runner', 'setuptools_scm>=3.3.1', ] |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
class OptionalBuildExt(build_ext): |
40
|
|
|
"""Allow the building of C extensions to fail.""" |
41
|
|
|
def run(self): |
42
|
|
|
try: |
43
|
|
|
if os.environ.get('SETUPPY_FORCE_PURE'): |
44
|
|
|
raise Exception('C extensions disabled (SETUPPY_FORCE_PURE)!') |
45
|
|
|
super().run() |
46
|
|
|
except Exception as e: |
47
|
|
|
self._unavailable(e) |
48
|
|
|
self.extensions = [] # avoid copying missing files (it would fail). |
49
|
|
|
|
50
|
|
|
def _unavailable(self, e): |
51
|
|
|
print('*' * 80) |
52
|
|
|
print('''WARNING: |
53
|
|
|
|
54
|
|
|
An optional code optimization (C extension) could not be compiled. |
55
|
|
|
|
56
|
|
|
Optimizations for this package will not be available! |
57
|
|
|
''') |
58
|
|
|
|
59
|
|
|
print('CAUSE:') |
60
|
|
|
print('') |
61
|
|
|
print(' ' + repr(e)) |
62
|
|
|
print('*' * 80) |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
class BinaryDistribution(Distribution): |
66
|
|
|
"""Distribution which almost always forces a binary package with platform name""" |
67
|
|
|
def has_ext_modules(self): |
68
|
|
|
return super().has_ext_modules() or not os.environ.get('SETUPPY_ALLOW_PURE') |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
def read(*names, **kwargs): |
72
|
|
|
with io.open(join(dirname(__file__), *names), encoding=kwargs.get('encoding', 'utf8')) as fh: |
73
|
|
|
return fh.read() |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
setup( |
77
|
|
|
name='trending-homebrew', |
78
|
|
|
use_scm_version={ |
79
|
|
|
'local_scheme': 'dirty-tag', |
80
|
|
|
'write_to': 'src/trending_homebrew/_version.py', |
81
|
|
|
'fallback_version': '0.1.0', |
82
|
|
|
}, |
83
|
|
|
license='MIT', |
84
|
|
|
description='Tool for identifying trending Homebrew formulae, casks, and build errors.', |
85
|
|
|
long_description='{}\n{}'.format( |
86
|
|
|
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')), |
87
|
|
|
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst')), |
88
|
|
|
), |
89
|
|
|
author='John Patrick Roach', |
90
|
|
|
author_email='[email protected]', |
91
|
|
|
url='https://github.com/johnpatrickroach/trending-homebrew', |
92
|
|
|
packages=find_packages('src'), |
93
|
|
|
package_dir={'': 'src'}, |
94
|
|
|
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], |
95
|
|
|
include_package_data=True, |
96
|
|
|
zip_safe=False, |
97
|
|
|
classifiers=[ |
98
|
|
|
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers |
99
|
|
|
'Development Status :: 4 - Beta', |
100
|
|
|
'Environment :: MacOS X', |
101
|
|
|
'Intended Audience :: Developers', |
102
|
|
|
'Intended Audience :: System Administrators', |
103
|
|
|
'License :: OSI Approved :: MIT License', |
104
|
|
|
'Natural Language :: English', |
105
|
|
|
'Operating System :: MacOS', |
106
|
|
|
'Operating System :: Unix', |
107
|
|
|
'Operating System :: POSIX', |
108
|
|
|
'Operating System :: Microsoft :: Windows', |
109
|
|
|
'Programming Language :: Python', |
110
|
|
|
'Programming Language :: Python :: 3', |
111
|
|
|
'Programming Language :: Python :: 3 :: Only', |
112
|
|
|
'Programming Language :: Python :: 3.7', |
113
|
|
|
'Programming Language :: Python :: 3.8', |
114
|
|
|
'Programming Language :: Python :: 3.9', |
115
|
|
|
'Programming Language :: Python :: 3.10', |
116
|
|
|
'Programming Language :: Python :: 3.11', |
117
|
|
|
'Programming Language :: Python :: Implementation :: CPython', |
118
|
|
|
'Programming Language :: Python :: Implementation :: PyPy', |
119
|
|
|
'Programming Language :: Ruby', |
120
|
|
|
# uncomment if you test on these interpreters: |
121
|
|
|
# 'Programming Language :: Python :: Implementation :: IronPython', |
122
|
|
|
# 'Programming Language :: Python :: Implementation :: Jython', |
123
|
|
|
# 'Programming Language :: Python :: Implementation :: Stackless', |
124
|
|
|
'Topic :: System :: Installation/Setup', |
125
|
|
|
'Topic :: System :: Software Distribution', |
126
|
|
|
'Topic :: System :: Systems Administration', |
127
|
|
|
'Topic :: Utilities', |
128
|
|
|
], |
129
|
|
|
project_urls={ |
130
|
|
|
'Documentation': 'https://trending-homebrew.readthedocs.io/', |
131
|
|
|
'Changelog': 'https://trending-homebrew.readthedocs.io/en/latest/changelog.html', |
132
|
|
|
'Issue Tracker': 'https://github.com/johnpatrickroach/trending-homebrew/issues', |
133
|
|
|
}, |
134
|
|
|
keywords=[ |
135
|
|
|
'homebrew', 'formulae', 'formula', 'casks', 'cask', |
136
|
|
|
'build', 'builds', 'error', 'errors', 'count', 'counts', |
137
|
|
|
'installs', 'items', 'trends', 'trending', 'top', 'macos', |
138
|
|
|
'brews', 'brew', 'tap', 'taps', 'cli', 'python', 'package', |
139
|
|
|
'pypi', 'pip', 'johnpatrickroach', 'better-wealth', |
140
|
|
|
'trending-homebrew', 'trending_homebrew', 'install' |
141
|
|
|
], |
142
|
|
|
python_requires='>=3.7', |
143
|
|
|
install_requires=requirements |
144
|
|
|
test_suite='tests', |
145
|
|
|
tests_require=test_requirements, |
146
|
|
|
extras_require={ |
147
|
|
|
# eg: |
148
|
|
|
# 'rst': ['docutils>=0.11'], |
149
|
|
|
# ':python_version=="2.6"': ['argparse'], |
150
|
|
|
}, |
151
|
|
|
setup_requires=setup_requirements |
152
|
|
|
entry_points={ |
153
|
|
|
'console_scripts': [ |
154
|
|
|
'trending-homebrew = trending_homebrew.cli:main', |
155
|
|
|
] |
156
|
|
|
}, |
157
|
|
|
cmdclass={'build_ext': OptionalBuildExt}, |
158
|
|
|
ext_modules=[ |
159
|
|
|
Extension( |
160
|
|
|
splitext(relpath(path, 'src').replace(os.sep, '.'))[0], |
161
|
|
|
sources=[path], |
162
|
|
|
extra_compile_args=CFLAGS.split(), |
163
|
|
|
extra_link_args=LFLAGS.split(), |
164
|
|
|
include_dirs=[dirname(path)], |
165
|
|
|
) |
166
|
|
|
for root, _, _ in os.walk('src') |
167
|
|
|
for path in glob(join(root, '*.c')) |
168
|
|
|
], |
169
|
|
|
distclass=BinaryDistribution, |
170
|
|
|
) |
171
|
|
|
|