|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 | 3 | import locale
|
| 4 | +import os |
| 5 | +import platform |
| 6 | +import sys |
| 7 | + |
4 | 8 | from setuptools import find_packages, setup
|
| 9 | +from setuptools.command.test import test as TestCommand |
5 | 10 |
|
6 | 11 | try:
|
7 |
| - locale.getlocale() |
8 |
| -except (ValueError, UnicodeError): |
| 12 | + lc = locale.getlocale() |
| 13 | + pf = platform.system() |
| 14 | + if pf != 'Windows' and lc == (None, None): |
| 15 | + locale.setlocale(locale.LC_ALL, 'C.UTF-8') |
| 16 | +except (ValueError, UnicodeError, locale.Error): |
9 | 17 | locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
10 | 18 |
|
11 |
| -with open('requirements.txt') as requirements: |
12 |
| - required = requirements.read().splitlines() |
| 19 | +VERSION = '0.4.0' |
| 20 | +DEPENDENCY_LINKS = [] |
| 21 | + |
| 22 | +SETUP_COMMANDS = {} |
| 23 | + |
| 24 | + |
| 25 | +def set_python_path(path): |
| 26 | + if 'PYTHONPATH' in os.environ: |
| 27 | + user_paths = os.environ['PYTHONPATH'].split(os.pathsep) |
| 28 | + user_paths.insert(0, path) |
| 29 | + os.environ['PYTHONPATH'] = os.pathsep.join(user_paths) |
| 30 | + else: |
| 31 | + os.environ['PYTHONPATH'] = path |
| 32 | + |
| 33 | + |
| 34 | +class PyTestCommand(TestCommand): |
| 35 | + """ |
| 36 | + From https://pytest.org/latest/goodpractices.html |
| 37 | + """ |
| 38 | + user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')] |
| 39 | + |
| 40 | + def initialize_options(self): |
| 41 | + TestCommand.initialize_options(self) |
| 42 | + self.pytest_args = [] |
| 43 | + |
| 44 | + def finalize_options(self): |
| 45 | + TestCommand.finalize_options(self) |
| 46 | + self.test_args = [] |
| 47 | + self.test_suite = True |
| 48 | + |
| 49 | + def run_tests(self): |
| 50 | + # import here, cause outside the eggs aren't loaded |
| 51 | + import pytest |
| 52 | + errno = pytest.main(self.pytest_args) |
| 53 | + sys.exit(errno) |
| 54 | + |
| 55 | + |
| 56 | +SETUP_COMMANDS['test'] = PyTestCommand |
| 57 | + |
| 58 | + |
| 59 | +__dir__ = os.path.dirname(__file__) |
| 60 | + |
| 61 | + |
| 62 | +def read_requirements(filename): |
| 63 | + """ |
| 64 | + Parse a requirements file. |
| 65 | +
|
| 66 | + Accepts vcs+ links, and places the URL into |
| 67 | + `DEPENDENCY_LINKS`. |
| 68 | +
|
| 69 | + :return: list of str for each package |
| 70 | + """ |
| 71 | + data = [] |
| 72 | + filename = os.path.join(__dir__, filename) |
| 73 | + with open(filename) as requirements: |
| 74 | + required = requirements.read().splitlines() |
| 75 | + for line in required: |
| 76 | + if not line or line.startswith('#'): |
| 77 | + continue |
| 78 | + |
| 79 | + if '+' in line[:4]: |
| 80 | + repo_link, egg_name = line.split('#egg=') |
| 81 | + if not egg_name: |
| 82 | + raise ValueError('Unknown requirement: {0}' |
| 83 | + .format(line)) |
| 84 | + |
| 85 | + DEPENDENCY_LINKS.append(repo_link) |
| 86 | + |
| 87 | + line = egg_name.replace('-', '==') |
| 88 | + |
| 89 | + data.append(line) |
| 90 | + |
| 91 | + return data |
| 92 | + |
| 93 | + |
| 94 | +required = read_requirements('requirements.txt') |
| 95 | + |
| 96 | +test_required = read_requirements('test-requirements.txt') |
| 97 | + |
| 98 | +filename = os.path.join(__dir__, 'README.rst') |
| 99 | +with open(filename) as readme: |
| 100 | + long_description = readme.read() |
| 101 | + |
| 102 | +extras_require = None |
| 103 | +EXTRAS_REQUIRE = {} |
| 104 | +data_files = None |
13 | 105 |
|
14 |
| -with open('test-requirements.txt') as requirements: |
15 |
| - test_required = requirements.read().splitlines() |
| 106 | +if extras_require: |
| 107 | + EXTRAS_REQUIRE = extras_require |
| 108 | +SETUP_COMMANDS.update({ |
| 109 | +}) |
16 | 110 |
|
17 | 111 | if __name__ == '__main__':
|
18 | 112 | setup(name='coala-quickstart',
|
19 |
| - version='0.4.0', |
| 113 | + version=VERSION, |
20 | 114 | description='A quickstart tool for coala',
|
21 | 115 | author='The coala developers',
|
22 |
| - maintainer='Satwik Kansal, Adrian Zatreanu, Alexandros Dimos, ' |
| 116 | + |
| 117 | + maintainer='Satwik Kansal, ' |
| 118 | + 'Adrian Zatreanu, ' |
| 119 | + 'Alexandros Dimos, ' |
23 | 120 | 'Adhityaa Chandrasekar',
|
24 | 121 | maintainer_email=( '[email protected], '
|
25 | 122 |
|
26 | 123 |
|
27 | 124 |
|
28 | 125 | url='https://github.com/coala/coala-quickstart',
|
29 | 126 | platforms='any',
|
30 |
| - packages=find_packages(exclude=['build.*', '*.tests.*', '*.tests']), |
| 127 | + packages=find_packages(exclude=('build.*', 'tests', 'tests.*')), |
31 | 128 | install_requires=required,
|
| 129 | + extras_require=EXTRAS_REQUIRE, |
32 | 130 | tests_require=test_required,
|
| 131 | + dependency_links=DEPENDENCY_LINKS, |
| 132 | + package_data={'coala_quickstart': ['VERSION']}, |
33 | 133 | license='AGPL-3.0',
|
34 |
| - long_description='coala-quickstart is a tool to help you ' |
35 |
| - 'quickly and easily get started with ' |
36 |
| - 'coala.', |
| 134 | + data_files=data_files, |
| 135 | + long_description=long_description, |
37 | 136 | entry_points={
|
38 | 137 | 'console_scripts': [
|
39 | 138 | 'coala-quickstart = coala_quickstart.coala_quickstart:main',
|
40 |
| - ]}, |
| 139 | + ], |
| 140 | + }, |
41 | 141 | # from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
42 | 142 | classifiers=[
|
43 | 143 | 'Development Status :: 4 - Beta',
|
|
57 | 157 | 'Programming Language :: Python :: Implementation :: CPython',
|
58 | 158 | 'Programming Language :: Python :: 3.4',
|
59 | 159 | 'Programming Language :: Python :: 3.5',
|
| 160 | + 'Programming Language :: Python :: 3.6', |
60 | 161 | 'Programming Language :: Python :: 3 :: Only',
|
61 | 162 |
|
62 | 163 | 'Topic :: Scientific/Engineering :: Information Analysis',
|
63 | 164 | 'Topic :: Software Development :: Quality Assurance',
|
64 |
| - 'Topic :: Text Processing :: Linguistic']) |
| 165 | + 'Topic :: Text Processing :: Linguistic'], |
| 166 | + cmdclass=SETUP_COMMANDS, |
| 167 | + ) |
0 commit comments