Skip to content

Commit

Permalink
Build setup.py and requirements files using moban
Browse files Browse the repository at this point in the history
coala-mobans provides a set of metadata common to
all repositories, with local overrides.

Related to coala/meta#117
  • Loading branch information
jayvdb committed Jul 10, 2018
1 parent 9a24071 commit 60116df
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 15 deletions.
27 changes: 27 additions & 0 deletions .moban.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
overrides: coala.yaml

name: coala-quickstart
contact: [email protected]
description: A quickstart tool for coala
current_version: 0.4.0
version: 0.4.0
build_version: 0.4.0
package_module: coala_quickstart
url: https://github.com/coala/coala-quickstart
docs_output_dir: false

maintainers: false
maintainer_list:
- Satwik Kansal
- Adrian Zatreanu
- Alexandros Dimos
- Adhityaa Chandrasekar
maintainer_emails:
- [email protected]
- [email protected]
- [email protected]
- [email protected]

entry_points:
console_scripts:
- coala-quickstart = coala_quickstart.coala_quickstart:main

dependencies:
# TODO: Remove lxml once the upstream issue https://github.com/vfaronov/httpolice/issues/5 with HTTpolice is fixed.
Expand All @@ -17,5 +41,8 @@ configuration:
configuration: .moban.yaml
configuration_dir: ../coala-mobans/
targets:
- setup.py: coala-setup.py.jj2
- requirements.txt: requirements.txt.jj2
- test-requirements.txt: test-requirements.txt.jj2
- coala_quickstart/VERSION: VERSION.jj2
- coala_quickstart/__init__.py: __init__.py.jj2
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ cache:
before_install:
- pip install setuptools -U
- pip install -r requirements.txt -r test-requirements.txt
- git clone https://gitlab.com/coala/mobans ../coala-mobans
- moban
- git diff --exit-code

script:
- pytest
Expand Down
1 change: 1 addition & 0 deletions coala_quickstart/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.0
13 changes: 13 additions & 0 deletions coala_quickstart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from os.path import join, dirname


VERSION_FILE = join(dirname(__file__), 'VERSION')


def get_version():
with open(VERSION_FILE, 'r') as ver:
return ver.readline().strip()


VERSION = get_version()
__version__ = VERSION
3 changes: 2 additions & 1 deletion coala_quickstart/coala_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from coala_utils.FilePathCompleter import FilePathCompleter
from coala_utils.Question import ask_question

from coala_quickstart import __version__
from coala_quickstart.interaction.Logo import print_welcome_message
from coala_quickstart.generation.InfoCollector import collect_info
from coala_quickstart.generation.Project import (
Expand Down Expand Up @@ -37,7 +38,7 @@ def _get_arg_parser():
)

arg_parser.add_argument(
'-v', '--version', action='version', version='0.4.0')
'-v', '--version', action='version', version=__version__)

arg_parser.add_argument(
'-C', '--non-interactive', const=True, action='store_const',
Expand Down
132 changes: 118 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,144 @@
#!/usr/bin/env python3

import locale
import os
import platform
import sys

import setuptools.command.build_py
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand

try:
locale.getlocale()
except (ValueError, UnicodeError):
lc = locale.getlocale()
pf = platform.system()
if pf != 'Windows' and lc == (None, None):
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
except (ValueError, UnicodeError, locale.Error):
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

with open('requirements.txt') as requirements:
required = requirements.read().splitlines()
VERSION = '0.4.0'
DEPENDENCY_LINKS = []

SETUP_COMMANDS = {}


def set_python_path(path):
if 'PYTHONPATH' in os.environ:
user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
user_paths.insert(0, path)
os.environ['PYTHONPATH'] = os.pathsep.join(user_paths)
else:
os.environ['PYTHONPATH'] = path


class PyTestCommand(TestCommand):
"""
From https://pytest.org/latest/goodpractices.html
"""
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 here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)


SETUP_COMMANDS['test'] = PyTestCommand


__dir__ = os.path.dirname(__file__)


def read_requirements(filename):
"""
Parse a requirements file.
Accepts vcs+ links, and places the URL into
`DEPENDENCY_LINKS`.
:return: list of str for each package
"""
data = []
filename = os.path.join(__dir__, filename)
with open(filename) as requirements:
required = requirements.read().splitlines()
for line in required:
if not line or line.startswith('#'):
continue

if '+' in line[:4]:
repo_link, egg_name = line.split('#egg=')
if not egg_name:
raise ValueError('Unknown requirement: {0}'
.format(line))

DEPENDENCY_LINKS.append(repo_link)

line = egg_name.replace('-', '==')

data.append(line)

return data


required = read_requirements('requirements.txt')

test_required = read_requirements('test-requirements.txt')

filename = os.path.join(__dir__, 'README.rst')
with open(filename) as readme:
long_description = readme.read()

extras_require = None
EXTRAS_REQUIRE = {}
data_files = None

with open('test-requirements.txt') as requirements:
test_required = requirements.read().splitlines()
if extras_require:
EXTRAS_REQUIRE = extras_require
SETUP_COMMANDS.update({
})

if __name__ == '__main__':
setup(name='coala-quickstart',
version='0.4.0',
version=VERSION,
description='A quickstart tool for coala',
author='The coala developers',
maintainer='Satwik Kansal, Adrian Zatreanu, Alexandros Dimos, '
author_email='[email protected]',
maintainer='Satwik Kansal, '
'Adrian Zatreanu, '
'Alexandros Dimos, '
'Adhityaa Chandrasekar',
maintainer_email=('[email protected], '
'[email protected], '
'[email protected], '
'[email protected]'),
url='https://github.com/coala/coala-quickstart',
platforms='any',
packages=find_packages(exclude=['build.*', '*.tests.*', '*.tests']),
packages=find_packages(exclude=('build.*', 'tests', 'tests.*')),
install_requires=required,
extras_require=EXTRAS_REQUIRE,
tests_require=test_required,
dependency_links=DEPENDENCY_LINKS,
package_data={'coala_quickstart': ['VERSION']},
license='AGPL-3.0',
long_description='coala-quickstart is a tool to help you '
'quickly and easily get started with '
'coala.',
data_files=data_files,
long_description=long_description,
entry_points={
'console_scripts': [
'coala-quickstart = coala_quickstart.coala_quickstart:main',
]},
],
},
# from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 4 - Beta',
Expand All @@ -57,8 +158,11 @@
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3 :: Only',

'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Text Processing :: Linguistic'])
'Topic :: Text Processing :: Linguistic'],
cmdclass=SETUP_COMMANDS,
)

0 comments on commit 60116df

Please sign in to comment.