forked from ispras/lingvodoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
130 lines (94 loc) · 3.58 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
126
127
128
129
import os
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.install import install
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md')) as f:
README = f.read()
with open(os.path.join(here, 'CHANGES.md')) as f:
CHANGES = f.read()
class React_Interface_Mixin(object):
"""
Adds ability to set up React-based interface to setuptools commands.
"""
def initialize_options(self):
"""
Initializes standard setuptools' command options and a React interface option.
"""
super().initialize_options()
self.react_interface = None
def setup_react_interface(self, lingvodoc_dir):
"""
Sets up React-based interface by copying its distribution files to appropriate locations.
"""
self.announce('Installing React-based interface')
interface_dir = os.path.expanduser(self.react_interface)
index_from_path = os.path.join(interface_dir, 'index.html')
index_to_path = os.path.join(lingvodoc_dir,
'views', 'v2', 'templates', 'new_interface.pt')
if os.path.exists(index_to_path):
os.remove(index_to_path)
self.copy_file(index_from_path, index_to_path)
assets_dir = os.path.join(interface_dir, 'assets')
self.copy_tree(assets_dir, os.path.join(
lingvodoc_dir, 'assets'))
class develop_with_interface(React_Interface_Mixin, develop):
"""
Extends 'develop' setup.py command with ability to develop React-based interface.
"""
user_options = develop.user_options + [
('react-interface=', None, 'path to React-based interface distribution')]
def run(self):
"""
Runs development installation, sets up React-based interface if required.
"""
develop.run(self)
if self.react_interface is not None:
self.setup_react_interface(
os.path.join(self.egg_path, 'lingvodoc'))
class install_with_interface(React_Interface_Mixin, install):
"""
Extends 'install' setup.py command with ability to install React-based interface.
"""
user_options = install.user_options + [
('react-interface=', None, 'path to React-based interface distribution')]
def run(self):
"""
Performs installation, then installs React-based interface if required.
"""
install.run(self)
if self.react_interface is not None:
self.setup_react_interface(
os.path.join(self.install_lib, 'lingvodoc'))
requires = [
'pyramid',
]
setup(name='lingvodoc',
version='2.1.1',
description='lingvodoc',
long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='Oleg Borisenko',
author_email='[email protected]',
url='https://lingvodoc.ispras.ru/',
keywords='web wsgi bfg pylons pyramid sqlalchemy',
packages=find_packages(exclude=['tests', 'tests.*']),
include_package_data=True,
zip_safe=False,
test_suite='lingvodoc',
install_requires=requires,
entry_points="""\
[paste.app_factory]
main = lingvodoc:main
[console_scripts]
initialize_lingvodoc_db = lingvodoc.scripts.initializedb:main
""",
cmdclass={
'develop': develop_with_interface,
'install': install_with_interface},
)