Skip to content

Commit 5bf89d7

Browse files
committed
🤝 Merge branch 'master' of https://github.com/moremoban/setupmobans
2 parents b74f749 + c8f715b commit 5bf89d7

File tree

8 files changed

+158
-24
lines changed

8 files changed

+158
-24
lines changed

README.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ setupmobans
55
.. image:: https://api.travis-ci.org/moremoban/setupmobans.svg?branch=master
66
:target: http://travis-ci.org/moremoban/setupmobans
77

8+
Scaffolding templates for your Python project. It is used with `yehua <https://github.com/chfw/yehua>`_
9+
and `pyexcel <https://github.com/pyexcel/pyexcel>`_.
10+
11+
Features
12+
================================================================================
13+
14+
setup.py
15+
----------
16+
17+
1. flake8 compliant setup.py
18+
19+
2. feature parity with `kennethreitz/setup.py <https://github.com/kennethreitz/setup.py>`_
20+
21+
- automatically upload to pypi without using twine
22+
23+
- automatically do git release while uploading to pypi
24+
25+
3. configured to build universial wheels by default
826

927
Installation
1028
================================================================================
@@ -15,3 +33,21 @@ You can get it:
1533
1634
$ git clone http://github.com/moremoban/setupmobans.git
1735
36+
37+
Notes
38+
================================================================================
39+
40+
41+
In order to run, `python setup.py publish`, you will have setup `.pypirc` in
42+
your home folder as::
43+
44+
[distutils]
45+
index-servers =
46+
pypi
47+
48+
[pypi]
49+
username=your_name
50+
password=your_password
51+
52+
53+
And you need `gease` installed too.

templates/README.rst.jj2

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,7 @@
2222
Installation
2323
================================================================================
2424

25-
{% if release != '0.0.0' %}
26-
27-
You can install it via pip:
28-
29-
.. code-block:: bash
30-
31-
$ pip install {{name}}
32-
33-
34-
or clone it and install it:
35-
{% endif %}
36-
37-
.. code-block:: bash
38-
39-
$ git clone http://github.com/{{organisation}}/{{name}}.git
40-
$ cd {{name}}
41-
$ python setup.py install
25+
{% include "installation.rst.jj2" %}
4226

4327
{%block bottom_block%}
4428
{%endblock%}

templates/__init__.py.jj2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# flake8: noqa
2+
from {{name|replace('-', '_')}}._version import __version__
3+
from {{name|replace('-', '_')}}._version import __author__

templates/_version.py.jj2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = '{{version}}'
2+
__author__ = '{{author}}'

templates/docs/source/conf.py.jj2

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
{%block additional_imports%}
3+
{%endblock%}
4+
DESCRIPTION = (
5+
{% for i in range(0, description|length, 70) %}
6+
'{{ description[i:(70+i)] }}' +
7+
{% endfor %}
8+
''
9+
)
10+
extensions = [
11+
'sphinx.ext.autodoc',
12+
'sphinx.ext.doctest',
13+
'sphinx.ext.intersphinx',
14+
'sphinx.ext.viewcode',
15+
{%block SPHINX_EXTENSIONS%}
16+
{%endblock%}
17+
]
18+
19+
templates_path = ['_templates']
20+
source_suffix = '.rst'
21+
master_doc = 'index'
22+
23+
project = u'{{name}}'
24+
copyright = u'{{copyright_year}} {{company}}'
25+
version = '{{release}}'
26+
release = '{{version}}'
27+
exclude_patterns = []
28+
pygments_style = 'sphinx'
29+
{%block custom_doc_theme%}
30+
html_theme = 'default'
31+
{%endblock%}
32+
html_static_path = ['_static']
33+
htmlhelp_basename = '{{name}}doc'
34+
latex_elements = {}
35+
latex_documents = [
36+
('index', '{{name}}.tex',
37+
'{{name}} Documentation',
38+
'{{company}}', 'manual'),
39+
]
40+
man_pages = [
41+
('index', '{{name}}',
42+
'{{name}} Documentation',
43+
[u'{{company}}'], 1)
44+
]
45+
texinfo_documents = [
46+
('index', '{{name}}',
47+
'{{name}} Documentation',
48+
'{{company}}', '{{name}}',
49+
DESCRIPTION,
50+
'Miscellaneous'),
51+
]

templates/installation.rst.jj2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% if release != '0.0.0' %}
2+
3+
You can install it via pip:
4+
5+
.. code-block:: bash
6+
7+
$ pip install {{name}}
8+
9+
10+
or clone it and install it:
11+
{% endif %}
12+
13+
.. code-block:: bash
14+
15+
$ git clone http://github.com/{{organisation}}/{{name}}.git
16+
$ cd {{name}}
17+
$ python setup.py install

templates/requirements.txt.jj2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% for dependency in dependencies: %}
2+
{{dependency}}
3+
{% endfor %}

templates/setup.py.jj2

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{% block header %}
2+
# Template by setupmobans
23
{% endblock %}
4+
import os
35
import codecs
6+
from shutil import rmtree
47
{% if external_module_library %}
58
from distutils.core import setup, Extension
69
{% else %}
7-
try:
8-
from setuptools import setup, find_packages
9-
except ImportError:
10-
from ez_setup import use_setuptools
11-
use_setuptools()
12-
from setuptools import setup, find_packages
10+
from setuptools import setup, find_packages, Command
1311
{%endif%}
1412
{%block platform_block%}
1513
from platform import python_implementation
@@ -124,6 +122,42 @@ EXTRAS_REQUIRE = {
124122
EXTRAS_REQUIRE = {}
125123
{% endif %}
126124
{% endif %}
125+
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
126+
sys.executable)
127+
GS_COMMAND = ('gs {{name}} v{{release}} ' +
128+
"Find {{release}} in changelog for more details")
129+
here = os.path.abspath(os.path.dirname(__file__))
130+
131+
132+
class PublishCommand(Command):
133+
"""Support setup.py upload."""
134+
135+
description = 'Build and publish the package on github and pypi'
136+
user_options = []
137+
138+
@staticmethod
139+
def status(s):
140+
"""Prints things in bold."""
141+
print('\033[1m{0}\033[0m'.format(s))
142+
143+
def initialize_options(self):
144+
pass
145+
146+
def finalize_options(self):
147+
pass
148+
149+
def run(self):
150+
try:
151+
self.status('Removing previous builds…')
152+
rmtree(os.path.join(here, 'dist'))
153+
except OSError:
154+
pass
155+
156+
self.status('Building Source and Wheel (universal) distribution…')
157+
if os.system(GS_COMMAND) == 0:
158+
os.system(PUBLISH_COMMAND)
159+
160+
sys.exit()
127161

128162

129163
def read_files(*files):
@@ -196,5 +230,9 @@ if __name__ == '__main__':
196230
entry_points=ENTRY_POINTS,
197231
{% endif %}
198232
{% endif%}
199-
classifiers=CLASSIFIERS
233+
classifiers=CLASSIFIERS,
234+
setup_requires=['gease'],
235+
cmdclass={
236+
'publish': PublishCommand,
237+
}
200238
)

0 commit comments

Comments
 (0)