🤝 sync with latest setupmobans

This commit is contained in:
chfw 2017-10-23 21:39:07 +01:00
parent 88924f1728
commit 5f4756361f
12 changed files with 119 additions and 294 deletions

View File

@ -0,0 +1,13 @@
{% extends "README.rst.jj2" %}
{%block features%}
{%include "description.rst.jj2" %}
{%endblock%}
{%block bottom_block%}
License
================================================================================
New BSD
{%endblock%}

View File

@ -1,44 +0,0 @@
================================================================================
{{name}} - {{description}}
================================================================================
.. image:: https://api.travis-ci.org/{{organisation}}/{{name}}.svg?branch=master
:target: http://travis-ci.org/{{organisation}}/{{name}}
.. image:: https://codecov.io/github/{{organisation}}/{{name}}/coverage.png
:target: https://codecov.io/github/{{organisation}}/{{name}}
{%block documentation_link%}
.. image:: https://readthedocs.org/projects/{{name|lower}}/badge/?version=latest
:target: http://{{name|lower}}.readthedocs.org/en/latest/
{%endblock%}
.. image:: https://badges.gitter.im/chfw_lml/Lobby.svg
:alt: Join the chat at https://gitter.im/chfw_lml/Lobby
:target: https://gitter.im/chfw_lml/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
{%include "description.rst.jj2" %}
Installation
================================================================================
You can install it via pip:
.. code-block:: bash
$ pip install {{name}}
or clone it and install it:
.. code-block:: bash
$ git clone https://github.com/{{organisation}}/{{name}}.git
$ cd {{name}}
$ python setup.py install
License
================================================================================
New BSD

View File

@ -0,0 +1,5 @@
{%extends "setup.py.jj2"%}
{%block platform_block%}
{%endblock %}

View File

@ -1,54 +0,0 @@
# -*- coding: utf-8 -*-
{%block additional_imports%}
{%endblock%}
DESCRIPTION = (
{% for i in range(0, description|length, 70) %}
'{{ description[i:(70+i)] }}' +
{% endfor %}
''
)
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
{%block SPHINX_EXTENSIONS%}
{%endblock%}
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'{{name}}'
copyright = u'{{copyright_year}} {{company}}'
version = '{{release}}'
release = '{{version}}'
exclude_patterns = []
pygments_style = 'sphinx'
{%block custom_doc_theme%}
html_theme = 'default'
{%endblock%}
html_static_path = ['_static']
htmlhelp_basename = '{{name}}doc'
latex_elements = {}
latex_documents = [
('index', '{{name}}.tex',
'{{name}} Documentation',
'{{company}}', 'manual'),
]
man_pages = [
('index', '{{name}}',
'{{name}} Documentation',
[u'{{company}}'], 1)
]
texinfo_documents = [
('index', '{{name}}',
'{{name}} Documentation',
'{{company}}', '{{name}}',
DESCRIPTION,
'Miscellaneous'),
]
{%block additional_config%}
{%endblock%}

View File

@ -1,6 +1,7 @@
{%extends "docs/source/conf.py.jj2"%}
{%block SPHINX_EXTENSIONS%}
'sphinx.ext.napoleon',
'sphinxcontrib.spelling'
{%endblock%}

View File

@ -1,169 +0,0 @@
{% if external_module_library %}
from distutils.core import setup, Extension
{% else %}
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
{%endif%}
{%block compat_block%}
import sys
PY2 = sys.version_info[0] == 2
PY26 = PY2 and sys.version_info[1] < 7
{%endblock%}
NAME = '{{name}}'
AUTHOR = '{{author}}'
VERSION = '{{version}}'
EMAIL = '{{contact}}'
LICENSE = '{{license}}'
{% if command_line_interface %}
ENTRY_POINTS = {
'console_scripts': [
'{{command_line_interface}} = {{ entry_point }}'
]
}
{% endif %}
DESCRIPTION = (
{% for i in range(0, description|length, 70) %}
'{{ description[i:(70+i)] }}' +
{% endfor %}
''
)
KEYWORDS = [
{%block additional_keywords%}
{%endblock%}
]
CLASSIFIERS = [
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
{%block additional_classifiers%}
{%endblock %}
]
{%macro handle_complex_dependency(complex_one) -%}
{%set dependency, condition = complex_one.split(';')%}
{% if condition == 'python_version<"3"'%}
if PY2:
{% endif %}
{% if condition == 'python_version>="3"'%}
if not PY2:
{% endif %}
{% if condition == 'python_version<"2.7"'%}
if PY26:
{% endif %}
{% if condition == 'platform_python_implementation=="PyPy"'%}
if python_implementation == "PyPy":
{%endif%}
INSTALL_REQUIRES.append('{{dependency}}')
{%- endmacro %}
INSTALL_REQUIRES = [
{% for dependency in dependencies: %}
{% if ';' not in dependency: %}
'{{dependency}}',
{% endif %}
{% endfor %}
]
{% for dependency in dependencies: %}
{% if ';' in dependency: %}
{{handle_complex_dependency(dependency)}}
{% endif %}
{% endfor %}
{% if external_module_library %}
PYMODULE = Extension(
'{{name}}',
sources=[
{% for source in sources: %}
'{{source}}',
{% endfor %}
],
libraries=INSTALL_REQUIRES
)
{% else %}
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
{% if extra_dependencies or dependencies: %}
EXTRAS_REQUIRE = {
{% for dependency in extra_dependencies: %}
{% for key, value in dependency.items(): %}
'{{key}}': {{value}},
{% endfor %}
{% endfor %}
}
{% else: %}
EXTRAS_REQUIRE = {}
{% endif %}
{% endif %}
def read_files(*files):
"""Read files into setup"""
text = ""
for single_file in files:
content = read(single_file)
text = text + content + "\n"
return text
def read(afile):
"""Read a file into setup"""
with open(afile, 'r') as opened_file:
content = filter_out_test_code(opened_file)
content = "".join(list(content))
return content
def filter_out_test_code(file_handle):
found_test_code = False
for line in file_handle.readlines():
if line.startswith('.. testcode:'):
found_test_code = True
continue
if found_test_code is True:
if line.startswith(' '):
continue
else:
empty_line = line.strip()
if len(empty_line) == 0:
continue
else:
found_test_code = False
yield line
else:
yield line
if __name__ == '__main__':
setup(
name=NAME,
author=AUTHOR,
version=VERSION,
author_email=EMAIL,
description=DESCRIPTION,
long_description=read_files('README.rst', 'CHANGELOG.rst'),
license=LICENSE,
keywords=KEYWORDS,
{% if external_module_library %}
ext_modules=[PYMODULE],
{% else %}
extras_require=EXTRAS_REQUIRE,
tests_require=['nose'],
install_requires=INSTALL_REQUIRES,
packages=PACKAGES,
include_package_data=True,
zip_safe=False,
{% if command_line_interface %}
entry_points=ENTRY_POINTS,
{% endif %}
{% endif%}
classifiers=CLASSIFIERS
)

View File

@ -1,12 +1,12 @@
configuration:
configuration_dir: "commons/config"
template_dir:
- "commons/templates"
- "setupmobans/templates"
- ".moban.d"
configuration: lml.yml
targets:
- README.rst: README.rst.jj2
- setup.py: setup.py.jj2
- README.rst: CUSTOM_README.rst.jj2
- setup.py: custom_setup.py.jj2
- MANIFEST.in: MANIFEST.in.jj2
- requirements.txt: requirements.txt.jj2
- "docs/source/conf.py": "docs/source/myconf.py.jj2"
- "docs/source/index.rst": "docs/source/index.rst.jj2"

View File

@ -1,2 +1,3 @@
include README.rst
include LICENSE
include CHANGELOG.rst

View File

@ -5,16 +5,12 @@ lml - Load me later. A lazy loading plugin management system.
.. image:: https://api.travis-ci.org/chfw/lml.svg?branch=master
:target: http://travis-ci.org/chfw/lml
.. image:: https://codecov.io/github/chfw/lml/coverage.png
:target: https://codecov.io/github/chfw/lml
.. image:: https://codecov.io/gh/chfw/lml/branch/master/graph/badge.svg
:target: https://codecov.io/gh/chfw/lml
.. image:: https://readthedocs.org/projects/lml/badge/?version=latest
:target: http://lml.readthedocs.org/en/latest/
.. image:: https://badges.gitter.im/chfw_lml/Lobby.svg
:alt: Join the chat at https://gitter.im/chfw_lml/Lobby
:target: https://gitter.im/chfw_lml/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
**lml** seamlessly finds the lml based plugins from your current python
environment but loads your plugins on demand. It is designed to support
plugins that have external dependencies, especially bulky and/or
@ -38,7 +34,8 @@ the developer need to do the code refactoring by yourself and lml would lend you
Installation
================================================================================
You can install it via pip:
You can install lml via pip:
.. code-block:: bash

View File

@ -7,8 +7,8 @@ extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinxcontrib.spelling'
]
@ -19,7 +19,7 @@ master_doc = 'index'
project = u'lml'
copyright = u'2017 Onni Software Ltd.'
version = '0.0.1'
release = '0.0.1'
release = '0.0.2'
exclude_patterns = []
pygments_style = 'sphinx'
html_theme = 'default'
@ -43,5 +43,3 @@ texinfo_documents = [
DESCRIPTION,
'Miscellaneous'),
]
spelling_lang = 'en_GB'
spelling_word_list_filename = 'spelling_wordlist.txt'

View File

@ -1,9 +1,11 @@
name: "lml"
full_name: "Load me later. A lazy loading plugin management system."
organisation: "chfw"
author: "C.W."
contact: "wangc_2011(@)hotmail.com"
company: "Onni Software Ltd."
version: "0.0.1"
version: "0.0.2"
current_version: "0.0.2"
release: "0.0.1"
copyright_year: 2017
license: New BSD

View File

@ -1,27 +1,34 @@
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
# Template by setupmobans
import os
import sys
import codecs
from shutil import rmtree
from setuptools import setup, find_packages, Command
PY2 = sys.version_info[0] == 2
PY26 = PY2 and sys.version_info[1] < 7
NAME = 'lml'
AUTHOR = 'C.W.'
VERSION = '0.0.1'
VERSION = '0.0.2'
EMAIL = 'wangc_2011(@)hotmail.com'
LICENSE = 'New BSD'
DESCRIPTION = (
'Load me later. A lazy loading plugin management system.' +
''
)
URL = 'https://github.com/chfw/lml'
DOWNLOAD_URL = '%s/archive/0.0.1.tar.gz' % URL
FILES = ['README.rst', 'CHANGELOG.rst']
KEYWORDS = [
'python'
]
CLASSIFIERS = [
'Topic :: Office/Business',
'Topic :: Utilities',
'Topic :: Software Development :: Libraries',
'Programming Language :: Python',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
@ -36,6 +43,65 @@ INSTALL_REQUIRES = [
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
EXTRAS_REQUIRE = {}
# You do not need to read beyond this line
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
sys.executable)
GS_COMMAND = ('gs lml v0.0.1 ' +
"Find 0.0.1 in changelog for more details")
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
'Please install gease to enable it.')
UPLOAD_FAILED_MSG = ('Upload failed. please run "%s" yourself.')
HERE = os.path.abspath(os.path.dirname(__file__))
class PublishCommand(Command):
"""Support setup.py upload."""
description = 'Build and publish the package on github and pypi'
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status('Removing previous builds...')
rmtree(os.path.join(HERE, 'dist'))
except OSError:
pass
self.status('Building Source and Wheel (universal) distribution...')
run_status = True
if has_gease():
run_status = os.system(GS_COMMAND) == 0
else:
self.status(NO_GS_MESSAGE)
if run_status:
if os.system(PUBLISH_COMMAND) != 0:
self.status(UPLOAD_FAILED_MSG % PUBLISH_COMMAND)
sys.exit()
def has_gease():
"""
test if github release command is installed
visit http://github.com/moremoban/gease for more info
"""
try:
import gease # noqa
return True
except ImportError:
return False
def read_files(*files):
@ -49,7 +115,7 @@ def read_files(*files):
def read(afile):
"""Read a file into setup"""
with open(afile, 'r') as opened_file:
with codecs.open(afile, 'r', 'utf-8') as opened_file:
content = filter_out_test_code(opened_file)
content = "".join(list(content))
return content
@ -72,7 +138,11 @@ def filter_out_test_code(file_handle):
found_test_code = False
yield line
else:
yield line
for keyword in ['|version|', '|today|']:
if keyword in line:
break
else:
yield line
if __name__ == '__main__':
@ -82,7 +152,9 @@ if __name__ == '__main__':
version=VERSION,
author_email=EMAIL,
description=DESCRIPTION,
long_description=read_files('README.rst', 'CHANGELOG.rst'),
url=URL,
download_url=DOWNLOAD_URL,
long_description=read_files(*FILES),
license=LICENSE,
keywords=KEYWORDS,
extras_require=EXTRAS_REQUIRE,
@ -91,5 +163,8 @@ if __name__ == '__main__':
packages=PACKAGES,
include_package_data=True,
zip_safe=False,
classifiers=CLASSIFIERS
classifiers=CLASSIFIERS,
cmdclass={
'publish': PublishCommand,
}
)