Skip to content

Commit d5e0c3f

Browse files
committed
Build setup.py and requirements files using moban
coala-mobans provides a set of metadata common to all repositories, with local overrides. Related to coala/meta#117
1 parent 9a24071 commit d5e0c3f

File tree

6 files changed

+163
-15
lines changed

6 files changed

+163
-15
lines changed

.moban.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
overrides: coala.yaml
22

33
name: coala-quickstart
4+
5+
description: A quickstart tool for coala
6+
current_version: 0.4.0
7+
version: 0.4.0
8+
build_version: 0.4.0
9+
package_module: coala_quickstart
10+
url: https://github.com/coala/coala-quickstart
11+
docs_dir: false
12+
13+
maintainers: false
14+
maintainer_list:
15+
- Satwik Kansal
16+
- Adrian Zatreanu
17+
- Alexandros Dimos
18+
- Adhityaa Chandrasekar
19+
maintainer_emails:
20+
21+
22+
23+
24+
25+
entry_points:
26+
console_scripts:
27+
- coala-quickstart = coala_quickstart.coala_quickstart:main
428

529
dependencies:
630
# TODO: Remove lxml once the upstream issue https://github.com/vfaronov/httpolice/issues/5 with HTTpolice is fixed.
@@ -17,5 +41,8 @@ configuration:
1741
configuration: .moban.yaml
1842
configuration_dir: ../coala-mobans/
1943
targets:
44+
- setup.py: coala-setup.py.jj2
2045
- requirements.txt: requirements.txt.jj2
2146
- test-requirements.txt: test-requirements.txt.jj2
47+
- coala_quickstart/VERSION: VERSION.jj2
48+
- coala_quickstart/__init__.py: __init__.py.jj2

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ cache:
1010
before_install:
1111
- pip install setuptools -U
1212
- pip install -r requirements.txt -r test-requirements.txt
13+
- git clone https://gitlab.com/coala/mobans ../coala-mobans
14+
- moban
15+
- git diff --exit-code
1316

1417
script:
1518
- pytest

coala_quickstart/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.4.0

coala_quickstart/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from os.path import join, dirname
2+
3+
4+
VERSION_FILE = join(dirname(__file__), 'VERSION')
5+
6+
7+
def get_version():
8+
with open(VERSION_FILE, 'r') as ver:
9+
return ver.readline().strip()
10+
11+
12+
VERSION = get_version()
13+
__version__ = VERSION

coala_quickstart/coala_quickstart.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from coala_utils.FilePathCompleter import FilePathCompleter
99
from coala_utils.Question import ask_question
1010

11+
from coala_quickstart import __version__
1112
from coala_quickstart.interaction.Logo import print_welcome_message
1213
from coala_quickstart.generation.InfoCollector import collect_info
1314
from coala_quickstart.generation.Project import (
@@ -37,7 +38,7 @@ def _get_arg_parser():
3738
)
3839

3940
arg_parser.add_argument(
40-
'-v', '--version', action='version', version='0.4.0')
41+
'-v', '--version', action='version', version=__version__)
4142

4243
arg_parser.add_argument(
4344
'-C', '--non-interactive', const=True, action='store_const',

setup.py

+117-14
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,143 @@
11
#!/usr/bin/env python3
22

33
import locale
4+
import os
5+
import platform
6+
import sys
7+
48
from setuptools import find_packages, setup
9+
from setuptools.command.test import test as TestCommand
510

611
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):
917
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
1018

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
13105

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+
})
16110

17111
if __name__ == '__main__':
18112
setup(name='coala-quickstart',
19-
version='0.4.0',
113+
version=VERSION,
20114
description='A quickstart tool for coala',
21115
author='The coala developers',
22-
maintainer='Satwik Kansal, Adrian Zatreanu, Alexandros Dimos, '
116+
author_email='[email protected]',
117+
maintainer='Satwik Kansal, '
118+
'Adrian Zatreanu, '
119+
'Alexandros Dimos, '
23120
'Adhityaa Chandrasekar',
24121
maintainer_email=('[email protected], '
25122
26123
27124
28125
url='https://github.com/coala/coala-quickstart',
29126
platforms='any',
30-
packages=find_packages(exclude=['build.*', '*.tests.*', '*.tests']),
127+
packages=find_packages(exclude=('build.*', 'tests', 'tests.*')),
31128
install_requires=required,
129+
extras_require=EXTRAS_REQUIRE,
32130
tests_require=test_required,
131+
dependency_links=DEPENDENCY_LINKS,
132+
package_data={'coala_quickstart': ['VERSION']},
33133
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,
37136
entry_points={
38137
'console_scripts': [
39138
'coala-quickstart = coala_quickstart.coala_quickstart:main',
40-
]},
139+
],
140+
},
41141
# from http://pypi.python.org/pypi?%3Aaction=list_classifiers
42142
classifiers=[
43143
'Development Status :: 4 - Beta',
@@ -57,8 +157,11 @@
57157
'Programming Language :: Python :: Implementation :: CPython',
58158
'Programming Language :: Python :: 3.4',
59159
'Programming Language :: Python :: 3.5',
160+
'Programming Language :: Python :: 3.6',
60161
'Programming Language :: Python :: 3 :: Only',
61162

62163
'Topic :: Scientific/Engineering :: Information Analysis',
63164
'Topic :: Software Development :: Quality Assurance',
64-
'Topic :: Text Processing :: Linguistic'])
165+
'Topic :: Text Processing :: Linguistic'],
166+
cmdclass=SETUP_COMMANDS,
167+
)

0 commit comments

Comments
 (0)