forked from kliment/Printrun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·93 lines (73 loc) · 2.81 KB
/
setup.py
File metadata and controls
executable file
·93 lines (73 loc) · 2.81 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
#!/usr/bin/env python3
# This file is part of the Printrun suite.
#
# Printrun 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.
#
# Printrun 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 Printrun. If not, see <http://www.gnu.org/licenses/>.
import ast
import glob
from setuptools import Extension, find_namespace_packages, setup
def get_install_requires():
with open('requirements.txt') as f:
return f.readlines()
def get_version():
with open('printrun/printcore.py', encoding="utf-8") as f:
for line in f.readlines():
if line.startswith("__version__"):
return ast.literal_eval(line.split("=")[1].strip())
return "unknown"
def multiglob(*globs):
paths = []
for g in globs:
paths.extend(glob.glob(g))
return paths
def get_data_files():
# FIXME: Does this even work to install the desktop entries?
# Quote from setuptools.com: >>data_files is deprecated and should be
# avoided. Please check 'Data Files Support' for more information.<<
data_files = [
('share/icons/hicolor/256x256/apps',
multiglob('assets_raw/icons/*.png')),
('share/applications',
multiglob('assets_raw/desktop_entries/applications/*.desktop')),
('share/metainfo',
multiglob('assets_raw/desktop_entries/metainfo/*.appdata.xml')),
]
for locale in glob.glob('locale/*/LC_MESSAGES/'):
data_files.append((f'share/{locale}', glob.glob(f'{locale}/*.mo')))
return data_files
def get_packagedata():
"""bdist-wheels only copy data files into the wheel when they
are in a subdirectory of the package (printrun in this case)!"""
package_data = {
"printrun.assets.toolbar": ["*.svg"],
"printrun.assets.controls": ["*.png", ".svg"],
"printrun.assets.icons.pronterface": ["*.png"],
}
return package_data
def get_extensions():
extensions = [
Extension(name="printrun.gcoder_line",
sources=["printrun/gcoder_line.pyx"])
]
return extensions
setup(
version=get_version(),
packages=find_namespace_packages(include=["printrun*",]),
package_data=get_packagedata(),
include_package_data=False,
data_files=get_data_files(),
scripts=["pronsole.py", "pronterface.py", "plater.py", "printcore.py"],
ext_modules=get_extensions(),
install_requires=get_install_requires(),
zip_safe=False,
)