Skip to content

Commit d89689e

Browse files
committed
modernized setup.py
1 parent 5304a81 commit d89689e

File tree

1 file changed

+60
-43
lines changed

1 file changed

+60
-43
lines changed

templates/setup.py.jj2

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,80 @@ except ImportError:
55
use_setuptools()
66
from setuptools import setup, find_packages
77

8-
with open("README.rst", 'r') as readme:
9-
README_txt = readme.read()
10-
11-
with open("CHANGELOG.rst", 'r') as changelog:
12-
README_txt += changelog.read()
8+
NAME = '{{name}}'
9+
AUTHOR = '{{author}}'
10+
VERSION = '{{version}}'
11+
EMAIL = '{{contact}}'
12+
LICENSE = '{{license}}'
13+
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
14+
DESCRIPTION = '{{description}}'
15+
KEYWORDS = [
16+
'excel',
17+
'python',
18+
'pyexcel',
19+
{%block additional_keywords%}
20+
{%endblock%}
21+
]
1322

14-
dependencies = [
23+
INSTALL_REQUIRES = [
1524
{% for dependency in dependencies: %}
1625
'{{dependency}}',
1726
{% endfor %}
1827
]
1928

2029
{% if extra_dependencies: %}
21-
extras = {
30+
EXTRAS_REQUIRE = {
2231
{% for dependency in extra_dependencies: %}
2332
{% for key, value in dependency.items(): %}
2433
'{{key}}': {{value}},
2534
{% endfor %}
2635
{% endfor %}
2736
}
2837
{% else: %}
29-
extras = {}
38+
EXTRAS_REQUIRE = {}
3039
{% endif %}
3140

32-
{%block extras %}
33-
{%endblock %}
41+
CLASSIFIERS = [
42+
'Topic :: Office/Business',
43+
'Topic :: Utilities',
44+
'Topic :: Software Development :: Libraries',
45+
'Programming Language :: Python',
46+
'License :: OSI Approved :: BSD License',
47+
'Intended Audience :: Developers',
48+
{%block additional_classifiers%}
49+
{%endblock %}
50+
]
51+
52+
53+
def read_files(*files):
54+
"""Read files into setup"""
55+
text = ""
56+
for single_file in files:
57+
text = text + read(single_file) + "\n"
58+
return text
59+
60+
61+
def read(afile):
62+
"""Read a file into setup"""
63+
with open(afile, 'r') as opened_file:
64+
return opened_file.read()
65+
3466

35-
setup(
36-
name='{{name}}',
37-
author='{{author}}',
38-
version='{{version}}',
39-
author_email='{{contact}}',
40-
url='https://github.com/{{organisation}}/{{name}}',
41-
description='{{description}}',
42-
install_requires=dependencies,
43-
extras_require=extras,
44-
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
45-
include_package_data=True,
46-
long_description=README_txt,
47-
zip_safe=False,
48-
tests_require=['nose'],
49-
keywords=[
50-
'excel',
51-
'python',
52-
'pyexcel',
53-
{%block additional_keywords%}
54-
{%endblock%}
55-
],
56-
license='{{license}}',
57-
classifiers=[
58-
'Topic :: Office/Business',
59-
'Topic :: Utilities',
60-
'Topic :: Software Development :: Libraries',
61-
'Programming Language :: Python',
62-
'License :: OSI Approved :: BSD License',
63-
'Intended Audience :: Developers',
64-
{%block additional_classifiers%}
65-
{%endblock %}
66-
]
67-
)
67+
if __name__ == '__main__':
68+
setup(
69+
name=NAME,
70+
author=AUTHOR,
71+
version=VERSION,
72+
author_email=EMAIL,
73+
description=DESCRIPTION,
74+
install_requires=INSTALL_REQUIRES,
75+
keywords=KEYWORDS,
76+
extras_require=EXTRAS_REQUIRE,
77+
packages=PACKAGES,
78+
include_package_data=True,
79+
long_description=read_files('README.rst', 'CHANGELOG.rst'),
80+
zip_safe=False,
81+
tests_require=['nose'],
82+
license=LICENSE,
83+
classifiers=CLASSIFIERS
84+
)

0 commit comments

Comments
 (0)