forked from riccardomc/storyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·142 lines (117 loc) · 4.14 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·142 lines (117 loc) · 4.14 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import sys
from os import getenv, path
from setuptools import find_packages, setup
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
from setuptools.command.install import install as _install
from setuptools.command.sdist import sdist as _sdist
root_dir = path.dirname(__file__)
# Read a file and return its as a string
def read(file_name):
return io.open(path.join(root_dir, file_name)).read()
name = 'storyscript'
version = None
release_version = None
# try loading the current version
try:
result = {'__file__': path.join(root_dir, name, 'Version.py')}
exec(read(path.join(name, 'Version.py')), result)
version = result['version']
release_version = result['release_version']
except FileNotFoundError:
pass
description = read('README.md')
short_description = ('StoryScript is an high-level language that can be used '
'to orchestrate microservices in an algorithmic way.')
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Other Scripting Engines',
'Topic :: Office/Business',
'Topic :: Software Development :: Build Tools',
'Topic :: Software Development :: Compilers'
]
requirements = [
'click==7.0',
'lark-parser==0.6.5',
'click-alias==0.1.1a2'
]
extras = [
'sphinx',
'guzzle-sphinx-theme'
]
###############################################################################
# Custom build steps
###############################################################################
def prepare_release(cwd, use_release):
version_file = path.join(cwd, name, 'VERSION')
if use_release:
version_text = release_version
else:
version_text = version
if path.isdir(path.dirname(version_file)):
print(f'writing version({version_text}) -> {version_file}')
with open(version_file, 'w') as f:
f.write(version_text)
class Install(_install):
def run(self):
_install.run(self)
self.execute(prepare_release, (self.install_lib, False),
msg='Preparing the installation')
class Sdist(_sdist):
def make_release_tree(self, basedir, files):
_sdist.make_release_tree(self, basedir, files)
self.execute(prepare_release, (basedir, True),
msg='Building the source release')
class BdistEgg(_bdist_egg):
def copy_metadata_to(self, egg_info):
_bdist_egg.copy_metadata_to(self, egg_info)
self.execute(prepare_release, (self.bdist_dir, True),
msg='Building the binary release')
class VerifyVersionCommand(_install):
"""Custom command to verify that the git tag matches our version"""
description = 'verify that the git tag matches our version'
def run(self):
tag = getenv('CIRCLE_TAG')
if tag != release_version:
info = ('Git tag: {0} does not match the '
'version of this app: {1}').format(tag, release_version)
sys.exit(info)
setup(name=name,
version=release_version,
description=short_description,
long_description=description,
long_description_content_type='text/markdown',
classifiers=classifiers,
download_url=('https://github.com/asyncy/storyscript/archive/'
f'{version}.zip'),
keywords='',
author='Asyncy',
author_email='support@asyncy.com',
url='http://storyscript.org',
license='MIT',
packages=find_packages(),
include_package_data=True,
zip_safe=True,
install_requires=requirements,
extras_require={
'docs': extras
},
python_requires='>=3.5',
entry_points={
'console_scripts': ['storyscript=storyscript.Cli:Cli.main']
},
cmdclass={
'install': Install,
'sdist': Sdist,
'bdist_egg': BdistEgg,
'verify': VerifyVersionCommand,
})