-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·114 lines (101 loc) · 3.23 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import distutils.cmd
import os
import re
import setuptools
import subprocess
import sys
# Suppress setup.py's stdout logging for our commands that output data
if any( x in ['requirements', 'version'] for x in sys.argv ):
sys.argv.insert(1, '-q')
requirements_dev = '''
jinja2
markdown==3.2.*
more_itertools
python-tr
pyyaml
requests
MarkupSafe==2.0.1
'''.strip().split('\n')
requirements_test = '''
ansible>=2.8
cffi==1.14.2
coverage
pytest
pytest-cov
pytest-tap
'''.strip().split('\n')
# https://jichu4n.com/posts/how-to-add-custom-build-steps-and-commands-to-setuppy/
class RequirementsCommand(distutils.cmd.Command):
""" Emit requirements """
description = 'emit requirements'
user_options = [
('dev', None, 'emit dev requirements'),
('test', None, 'emit test requirements')
]
def initialize_options(self):
self.dev = None
self.test = None
def finalize_options(self): pass
def run(self):
if self.test:
requirements = requirements_test
else:
requirements = requirements_dev
print('\n'.join(requirements))
return requirements
def version():
args = 'git describe --tags --always'.split(' ')
version = subprocess.check_output(args).decode().strip()
version = re.sub('^[vV]|\-\w{8}$', '', version)
version = re.sub('-', '.post', version)
return version
class VersionCommand(distutils.cmd.Command):
""" Emit version numbers """
description = 'Emit version numbers'
user_options = [
('version', None, 'current version number'),
('next', None, 'next version number'),
]
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
print(version())
return(version())
with open('README.md', 'r') as fh:
long_description = fh.read()
setuptools.setup(
name = 'inji',
version = '0.5.3', #version(),
description = 'Render parametrized Jinja2 templates at the CLI',
author = 'Shalom Bhooshi',
author_email = '[email protected]',
license = 'Apache License 2.0',
url = 'https://github.com/shalomb/inji',
download_url = 'https://github.com/shalomb/inji/tarball/{}'.format(version()),
packages = setuptools.find_packages(),
scripts = [ 'bin/inji' ],
install_requires = requirements_dev,
include_package_data = True,
zip_safe = False,
python_requires = '>=3.5',
long_description_content_type = 'text/markdown',
long_description = long_description,
keywords = [ 'jinja', 'jinja2', 'templating' ],
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: System :: Systems Administration'
],
cmdclass = {
'requirements': RequirementsCommand,
'version': VersionCommand,
}
)