-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
119 lines (98 loc) · 3.29 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
#!/usr/bin/env python3
import os
import shutil
import sys
from distutils.command.install_data import install_data
from setuptools import setup, find_packages
from setuptools.command.install import install
from citramanik import __version__, __website_url__, __author__, __title__
# Clear previous build
if os.path.isdir("dist"):
shutil.rmtree("dist")
if os.path.isdir("build"):
shutil.rmtree("build")
NAME="citramanik-qt"
LIBNAME="citramanik"
def get_subpackages(name):
p = []
for root, _dirname, _filename in os.walk(name):
if os.path.isfile(os.path.join(root, '__init__.py')):
p.append('.'.join(root.split(os.sep)))
return p
def get_packages():
packages = get_subpackages(LIBNAME)
return packages
def get_data_files():
"""
Return data_files in a platform dependent manner.
"""
if sys.platform.startswith('linux'):
data_files = [('share/applications', ['scripts/citramanik-qt.desktop']),
('share/icons/', ['icons/linux/citramanik-qt.png']),
('share/metainfo',
['scripts/id.devlovers.citramanik.appdata.xml'])]
elif os.name == 'nt':
# TODO add windows stuffs here
data_files = []
else:
data_files = []
return data_files
# =============================================================================
# Make Linux detect Citramanik desktop file (will not work with wheels)
# =============================================================================
class CustomInstallData(install_data):
def run(self):
install_data.run(self)
if sys.platform.startswith('linux'):
try:
subprocess.call(['update-desktop-database'])
except:
print("ERROR: unable to update desktop database",
file=sys.stderr)
CMDCLASS = {'install_data': CustomInstallData}
# =============================================================================
# Main scripts
# =============================================================================
# NOTE: the '[...]_win_post_install.py' script is installed even on non-Windows
# platforms due to a bug in pip installation process
# See spyder-ide/spyder#1158.
#SCRIPTS = ['%s_win_post_install.py' % NAME]
SCRIPTS = []
SCRIPTS.append('citramanik')
#if os.name == 'nt':
# SCRIPTS += ['citramanik.bat']
#=================
# Setup Arguments
#=================
setup_args = dict(
name=NAME,
version=__version__,
scripts=[os.path.join('scripts', fname) for fname in SCRIPTS],
platforms=["Windows", "Linux", "Mac OS-X"],
python_requires='>=3.7',
packages=get_packages(),
data_files=get_data_files(),
url=__website_url__,
license="GPL-3.0",
author=__author__,
author_email="citramanik@dev-is.my.id",
description="Your next way to export your Inkscape work for all purpose quickly",
cmdclass=CMDCLASS
)
install_requires = [
"appdirs==1.4.4",
"lxml==4.6.3",
"Pillow==8.1.2",
"PyQt5<5.16",
]
setup_args['install_requires'] = install_requires
setup_args['entry_points'] = {
'gui_scripts': [
'citramanik-qt = citramanik.main:main'
]
}
setup_args.pop('scripts', None)
#======================
# Main Setup execution
#======================
setup(**setup_args)