|
1
|
|
|
import os |
|
2
|
|
|
import distutils.file_util as file_util |
|
3
|
|
|
import distutils.dir_util as dir_util |
|
4
|
|
|
import subprocess |
|
5
|
|
|
|
|
6
|
|
|
from setuptools import setup, find_packages, Command |
|
7
|
|
|
|
|
8
|
|
|
here = os.path.abspath(os.path.dirname(__file__)) |
|
9
|
|
|
with open(os.path.join(here, 'README.rst')) as f: |
|
10
|
|
|
README = f.read() |
|
11
|
|
|
with open(os.path.join(here, 'CHANGES.rst')) as f: |
|
12
|
|
|
CHANGES = f.read() |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
def copy_files_scaffolds(filename, output_dir): |
|
16
|
|
|
source_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), filename)) |
|
17
|
|
|
dest_dir = os.path.join(os.path.dirname(__file__), 'atramhasis', 'scaffolds', output_dir, filename + '_tmpl') |
|
18
|
|
|
file_util.copy_file(source_dir, dest_dir, update=True) |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
def copy_static_scaffold(output_dir): |
|
22
|
|
|
source_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'atramhasis', 'static')) |
|
23
|
|
|
dest_dir = os.path.join(os.path.dirname(__file__), 'atramhasis', 'scaffolds', output_dir, '+package+', 'static') |
|
24
|
|
|
dir_util.copy_tree(os.path.join(source_dir, 'css'), os.path.join(dest_dir, 'css'), update=True) |
|
25
|
|
|
dir_util.copy_tree(os.path.join(source_dir, 'img'), os.path.join(dest_dir, 'img'), update=True) |
|
26
|
|
|
dir_util.copy_tree(os.path.join(source_dir, 'js'), os.path.join(dest_dir, 'js'), update=True) |
|
27
|
|
|
dir_util.copy_tree(os.path.join(source_dir, 'scss', 'atramhasis'), os.path.join(dest_dir, 'scss', 'atramhasis'), |
|
28
|
|
|
update=True) |
|
29
|
|
|
dir_util.mkpath(os.path.join(dest_dir, 'admin')) |
|
30
|
|
|
file_util.copy_file( |
|
31
|
|
|
os.path.join(source_dir, 'admin', '.bowerrc'), |
|
32
|
|
|
os.path.join(dest_dir, 'admin', '.bowerrc'), |
|
33
|
|
|
update=True |
|
34
|
|
|
) |
|
35
|
|
|
file_util.copy_file( |
|
36
|
|
|
os.path.join(source_dir, 'admin', 'bower.json'), |
|
37
|
|
|
os.path.join(dest_dir, 'admin', 'bower.json'), |
|
38
|
|
|
update=True |
|
39
|
|
|
) |
|
40
|
|
|
file_util.copy_file( |
|
41
|
|
|
os.path.join(source_dir, 'admin', 'Gruntfile.js'), |
|
42
|
|
|
os.path.join(dest_dir, 'admin', 'Gruntfile.js'), |
|
43
|
|
|
update=True |
|
44
|
|
|
) |
|
45
|
|
|
file_util.copy_file( |
|
46
|
|
|
os.path.join(source_dir, 'admin', 'package.json'), |
|
47
|
|
|
os.path.join(dest_dir, 'admin', 'package.json'), |
|
48
|
|
|
update=True |
|
49
|
|
|
) |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
def dojo_build(): |
|
53
|
|
|
print('-' * 50) |
|
54
|
|
|
print('==> check npm dependencies') |
|
55
|
|
|
libs = str(subprocess.check_output(["npm", "list", "-g", "bower", "grunt-cli"])) |
|
56
|
|
|
if 'bower' in libs: |
|
57
|
|
|
bower = True |
|
58
|
|
|
print('bower OK') |
|
59
|
|
|
else: |
|
60
|
|
|
bower = False |
|
61
|
|
|
print('bower KO, use \'npm install -g bower\' to install') |
|
62
|
|
|
if 'grunt-cli' in libs: |
|
63
|
|
|
gruntcli = True |
|
64
|
|
|
print('grunt-cli OK') |
|
65
|
|
|
else: |
|
66
|
|
|
gruntcli = False |
|
67
|
|
|
print('grunt-cli KO, use \'npm install -g grunt-cli\' to install') |
|
68
|
|
|
if bower and gruntcli: |
|
69
|
|
|
print('==> running grunt build') |
|
70
|
|
|
subprocess.call(["grunt", "-v", "build"], cwd="atramhasis/static/admin") |
|
71
|
|
|
print('-' * 50) |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
class PrepareScaffold(Command): |
|
75
|
|
|
user_options = [] |
|
76
|
|
|
|
|
77
|
|
|
def initialize_options(self): |
|
78
|
|
|
pass |
|
79
|
|
|
|
|
80
|
|
|
def finalize_options(self): |
|
81
|
|
|
pass |
|
82
|
|
|
|
|
83
|
|
|
def run(self): |
|
84
|
|
|
dojo_build() |
|
85
|
|
|
copy_files_scaffolds("requirements.txt", "atramhasis_demo") |
|
86
|
|
|
copy_files_scaffolds("requirements-dev.txt", "atramhasis_demo") |
|
87
|
|
|
copy_files_scaffolds("requirements.txt", "atramhasis_scaffold") |
|
88
|
|
|
copy_files_scaffolds("requirements-dev.txt", "atramhasis_scaffold") |
|
89
|
|
|
copy_static_scaffold("atramhasis_scaffold") |
|
90
|
|
|
copy_static_scaffold("atramhasis_demo") |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
requires = [ |
|
94
|
|
|
'pyramid', |
|
95
|
|
|
'pyramid_tm', |
|
96
|
|
|
'SQLAlchemy', |
|
97
|
|
|
'transaction', |
|
98
|
|
|
'zope.sqlalchemy', |
|
99
|
|
|
'waitress', |
|
100
|
|
|
'skosprovider', |
|
101
|
|
|
'skosprovider_sqlalchemy', |
|
102
|
|
|
'skosprovider_rdf', |
|
103
|
|
|
'skosprovider_getty', |
|
104
|
|
|
'skosprovider_heritagedata', |
|
105
|
|
|
'pyramid_skosprovider', |
|
106
|
|
|
'language_tags', |
|
107
|
|
|
'pyramid_jinja2', |
|
108
|
|
|
'alembic', |
|
109
|
|
|
'babel', |
|
110
|
|
|
'colander', |
|
111
|
|
|
'requests', |
|
112
|
|
|
'dogpile.cache', |
|
113
|
|
|
'six', |
|
114
|
|
|
'pyramid_rewrite' |
|
115
|
|
|
] |
|
116
|
|
|
|
|
117
|
|
|
setup(name='atramhasis', |
|
118
|
|
|
version='0.5.0b1', |
|
119
|
|
|
description='A web based editor for thesauri adhering to the SKOS specification.', |
|
120
|
|
|
long_description=README + '\n\n' + CHANGES, |
|
121
|
|
|
classifiers=[ |
|
122
|
|
|
"Development Status :: 4 - Beta", |
|
123
|
|
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", |
|
124
|
|
|
"Programming Language :: Python", |
|
125
|
|
|
"Framework :: Pyramid", |
|
126
|
|
|
"Topic :: Internet :: WWW/HTTP", |
|
127
|
|
|
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application", |
|
128
|
|
|
"Programming Language :: Python :: 2.7", |
|
129
|
|
|
"Programming Language :: Python :: 3.4", |
|
130
|
|
|
"Programming Language :: Python :: 3.5" |
|
131
|
|
|
], |
|
132
|
|
|
author='Flanders Heritage Agency', |
|
133
|
|
|
author_email='[email protected]', |
|
134
|
|
|
url='http://atramhasis.readthedocs.org', |
|
135
|
|
|
keywords='web wsgi pyramid SKOS thesaurus vocabulary', |
|
136
|
|
|
license='GPLv3', |
|
137
|
|
|
packages=find_packages(), |
|
138
|
|
|
include_package_data=True, |
|
139
|
|
|
zip_safe=False, |
|
140
|
|
|
test_suite='atramhasis', |
|
141
|
|
|
install_requires=requires, |
|
142
|
|
|
entry_points="""\ |
|
143
|
|
|
[paste.app_factory] |
|
144
|
|
|
main = atramhasis:main |
|
145
|
|
|
[console_scripts] |
|
146
|
|
|
initialize_atramhasis_db = atramhasis.scripts.initializedb:main |
|
147
|
|
|
import_file = atramhasis.scripts.import_file:main |
|
148
|
|
|
[pyramid.scaffold] |
|
149
|
|
|
atramhasis_scaffold=atramhasis.scaffolds:AtramhasisTemplate |
|
150
|
|
|
atramhasis_demo=atramhasis.scaffolds:AtramhasisDemoTemplate |
|
151
|
|
|
""", |
|
152
|
|
|
cmdclass={ |
|
153
|
|
|
'prepare': PrepareScaffold |
|
154
|
|
|
} |
|
155
|
|
|
) |
|
156
|
|
|
|