|
1 | | -""" Setup file for intelmq-manager |
| 1 | +""" |
| 2 | +Setup file for intelmq-manager |
2 | 3 |
|
3 | 4 | SPDX-FileCopyrightText: 2020 IntelMQ Team <intelmq-team@cert.at> |
4 | 5 | SPDX-License-Identifier: AGPL-3.0-or-later |
5 | 6 | """ |
6 | | -from setuptools import find_packages, setup |
7 | 7 |
|
8 | | -import pathlib |
9 | | -import shutil |
10 | | -from mako.lookup import TemplateLookup |
| 8 | +from setuptools import find_packages, setup |
11 | 9 |
|
12 | 10 | from intelmq_manager.version import __version__ |
13 | 11 |
|
14 | | -def render_page(pagename:str, **template_args) -> str: |
15 | | - template_dir = pathlib.Path('intelmq_manager/templates') |
16 | | - template_lookup = TemplateLookup(directories=[template_dir], default_filters=["h"], input_encoding='utf8') |
17 | | - template = template_lookup.get_template(f'{pagename}.mako') |
18 | | - |
19 | | - return template.render(pagename=pagename, **template_args) |
20 | | - |
21 | | -def buildhtml(): |
22 | | - outputdir = pathlib.Path('html') |
23 | | - outputdir.mkdir(parents=True, exist_ok=True) |
24 | | - |
25 | | - htmlfiles = ["configs", "management", "monitor", "check", "about", "index"] |
26 | | - for filename in htmlfiles: |
27 | | - print(f"Rendering {filename}.html") |
28 | | - html = render_page(filename) |
29 | | - outputdir.joinpath(f"{filename}.html").write_text(html) |
30 | | - |
31 | | - staticfiles = ["css", "images", "js", "plugins", "less"] |
32 | | - for filename in staticfiles: |
33 | | - print(f"Copying {filename} recursively") |
34 | | - src = pathlib.Path('intelmq_manager/static') / filename |
35 | | - dst = outputdir / filename |
36 | | - if dst.exists(): |
37 | | - shutil.rmtree(dst) |
38 | | - shutil.copytree(src, dst) |
39 | | - |
40 | | - print('rendering dynvar.js') |
41 | | - rendered = render_page('dynvar', allowed_path='/opt/intelmq/var/lib/bots/', controller_cmd='intelmq') |
42 | | - outputdir.joinpath('js/dynvar.js').write_text(rendered) |
43 | | - |
44 | | -# Before running setup, we build the html files in any case |
45 | | -buildhtml() |
46 | | - |
47 | | -htmlsubdirs = [directory for directory in pathlib.Path('html').glob('**') if directory.is_dir()] |
48 | | -data_files = [(f'/usr/share/intelmq_manager/{directory}', [str(x) for x in directory.glob('*') if x.is_file()]) for directory in htmlsubdirs] |
49 | | -data_files = data_files + [('/usr/share/intelmq_manager/html', [str(x) for x in pathlib.Path('html').iterdir() if x.is_file()])] |
50 | | -data_files = data_files + [('/etc/intelmq', ['contrib/manager-apache.conf'])] |
51 | 12 |
|
52 | 13 | setup( |
53 | 14 | name="intelmq-manager", |
| 15 | + maintainer='IntelMQ Team', |
| 16 | + maintainer_email='intelmq-team@cert.at', |
54 | 17 | version=__version__, |
55 | 18 | python_requires='>=3.5', |
56 | 19 | packages=find_packages(), |
57 | 20 | install_requires=[ |
58 | 21 | "intelmq-api", |
| 22 | + "mako", |
59 | 23 | ], |
60 | 24 | include_package_data=True, |
61 | 25 | url='https://github.com/certtools/intelmq-manager/', |
62 | 26 | description=("IntelMQ Manager is a graphical interface to manage" |
63 | 27 | " configurations for the IntelMQ framework."), |
64 | | - data_files=data_files |
| 28 | + data_files=[('/etc/intelmq', ['contrib/manager-apache.conf'])], # required for deb packaging |
| 29 | + package_data={'': ('manager-apache.conf', # works for the wheel package |
| 30 | + 'templates/*', |
| 31 | + 'static/css/*', |
| 32 | + 'static/images/*', |
| 33 | + 'static/js/*', |
| 34 | + 'static/less/*', |
| 35 | + 'static/plugins/*', |
| 36 | + 'static/plugins/bootstrap/*', |
| 37 | + 'static/plugins/dataTables/*', |
| 38 | + 'static/plugins/font-awesome-4.1.0/*', |
| 39 | + 'static/plugins/font-awesome-4.1.0/css/*', |
| 40 | + 'static/plugins/font-awesome-4.1.0/fonts/*', |
| 41 | + 'static/plugins/font-awesome-4.1.0/less/*', |
| 42 | + 'static/plugins/font-awesome-4.1.0/scss/*', |
| 43 | + 'static/plugins/fonts/*', |
| 44 | + 'static/plugins/metisMenu/*', |
| 45 | + 'static/plugins/vis.js/*', |
| 46 | + 'static/plugins/vis.js/img/*', |
| 47 | + 'static/plugins/vis.js/img/graph/*', |
| 48 | + 'static/plugins/vis.js/img/network/*', |
| 49 | + 'static/plugins/vis.js/img/timeline/*', |
| 50 | + )}, |
| 51 | + entry_points={ |
| 52 | + 'console_scripts': [ |
| 53 | + 'intelmq-manager-build = intelmq_manager.build:main', |
| 54 | + ], |
| 55 | + }, |
65 | 56 | ) |
0 commit comments