-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
executable file
·125 lines (97 loc) · 3.28 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
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright: 2014 Francois Lafont <[email protected]>
#
# License: GPL-3.0+
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import subprocess
from distutils.core import setup
from distutils.cmd import Command
from distutils.command.install import install
from distutils.command.clean import clean
## Important paths and filenames.
setup_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(setup_dir, 'build')
make_dir = os.path.join(setup_dir, 'make')
src_dir = os.path.join(setup_dir, 'src')
changelog = os.path.join(setup_dir, 'CHANGELOG.md')
readme = os.path.join(setup_dir, 'README.md')
def xia_build():
# Recreate a Cleaned build directory.
if os.path.isdir(build_dir):
shutil.rmtree(build_dir)
shutil.copytree(src_dir, build_dir)
# Generate .mo files.
subprocess.check_call([os.path.join(make_dir, "generate_mo.sh")])
# Build js in each theme and in vendors/.
subprocess.check_call([os.path.join(make_dir, "build_js.sh")])
def update_po():
subprocess.check_call([os.path.join(make_dir, "update_po.sh")])
class UpdatePO(Command):
user_options = []
def initialize_options(self):
"""Abstract method that is required to be overwritten"""
pass
def finalize_options(self):
"""Abstract method that is required to be overwritten"""
pass
def run(self):
update_po()
class BuildStandalone(Command):
user_options = []
def initialize_options(self):
"""Abstract method that is required to be overwritten"""
pass
def finalize_options(self):
"""Abstract method that is required to be overwritten"""
pass
def run(self):
xia_build()
class Install(install):
def run(self):
install.run(self)
xia_build()
class Clean(clean):
def run(self):
clean.run(self)
if os.path.isdir(build_dir):
shutil.rmtree(build_dir)
# Get the version of the application.
with open(changelog, 'r') as f:
line1 = f.readline()
words = line1.split()
version = words[1]
# Get the long description of the application.
with open(readme, 'r') as f:
long_description = f.read()
setup(
name='xia',
version=version,
packages=['xiaconverter'],
package_dir={ '': 'src'},
cmdclass={
'buildstandalone': BuildStandalone,
'install': Install,
'clean': Clean,
'update_po': UpdatePO,
},
author='Pascal Fautrero',
author_email='[email protected]',
description='Convert svg to full html5 interactive images',
long_description=long_description,
url='https://xia.funraiders.org',
license='GPL-3',
)