-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·142 lines (112 loc) · 3.65 KB
/
setup.py
File metadata and controls
executable file
·142 lines (112 loc) · 3.65 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 -*-
from distutils import dir_util
from setuptools import setup, Command, find_packages
from subprocess import call, PIPE, Popen, check_output
import os
from distutils.command.build import build as _build
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
from setuptools.command.develop import develop as _develop
from distutils.command.clean import clean as _clean
def which(program):
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
return exe_file
return None
class bdist_egg(_bdist_egg):
def run(self):
self.run_command('NpmInstall')
self.run_command('LibreJS')
self.run_command('SpriteGeneration')
_bdist_egg.run(self)
class NpmInstall(Command):
description = 'NPM install'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
npm = which("npm")
if npm:
call([npm, 'install', '--prefix=citkat/static'])
else:
print(
"Error: npm executable not found.")
exit(1)
class SpriteGeneration(Command):
description = 'Generate sprites, must be called after NpmInstall'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
svgstore_path = 'citkat/static/node_modules/svgstore-cli/bin/svgstore'
call([
svgstore_path,
'-o=citkat/static/node_modules/octicons/build/sprite.octicons.svg',
'citkat/static/node_modules/octicons/build/svg/*.svg'
])
class LibreJS(Command):
description = 'Collect all license information'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
cmd = ('citkat/static/node_modules/npm-license/bin/npm-license',
'-e=json', '--start=citkat/static/')
npm_license = Popen(cmd, stdout=PIPE)
file_cmd = ('tee', 'citkat/modules/librejs/licenses.json')
check_output(file_cmd, stdin=npm_license.stdout)
npm_license.wait()
class develop(_develop):
def run(self):
self.run_command('NpmInstall')
self.run_command('LibreJS')
self.run_command('SpriteGeneration')
_develop.run(self)
class clean(_clean):
def run(self):
if os.path.exists('citkat/static/node_modules/'):
dir_util.remove_tree('citkat/static/node_modules/', dry_run=self.dry_run)
_clean.run(self)
class build(_build):
sub_commands = [('NpmInstall', None)] + [('LibreJS', None)] + [
('SpriteGeneration', None)
] + _build.sub_commands
setup(
name='citkat',
long_description=__doc__,
packages=find_packages(exclude=('tests',)),
include_package_data=True,
zip_safe=False,
author='Martin Wiechmann',
author_email='mwiechmann@techfak.uni-bielefeld.de',
url='https://opensource.cit-ec.de/projects/citk/repository/citkat',
install_requires=[
'flask>=1.0.2',
'flask_restful>=0.3.6',
'lxml>=4.2.1',
'markdown>=2.6.11',
],
cmdclass={
'build': build,
'develop': develop,
'clean': clean,
'bdist_egg': bdist_egg,
'NpmInstall': NpmInstall,
'LibreJS': LibreJS,
'SpriteGeneration': SpriteGeneration,
},
entry_points={
'console_scripts': [
'citkat = citkat.__init__:develop',
],
},
license='GPL',
)