Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build setup.py and requirements files using moban #226

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had @coala.io domain e-mails

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is not to change the contents of setup.py . These values are just copies of what is in there.

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_dir: false

maintainers: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this False 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

template logic requires it in order to use maintainer_list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see.

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
131 changes: 117 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,143 @@
#!/usr/bin/env python3

import locale
import os
import platform
import sys

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 +157,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,
)