-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
55 lines (43 loc) · 1.5 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
import os
import sys
import argparse
def install():
if sys.platform.startswith('win'):
dest_path = os.path.join(os.environ['APPDATA'], 'inkscape', 'extensions')
else:
dest_path = os.path.join(os.environ['HOME'], '.config', 'inkscape', 'extensions')
current_dir = sys.path[0]
if not os.path.isdir(dest_path):
print("Target directory does not exist {}. Stopping".format(dest_path))
return
import shutil
import glob
filenames = []
for ext in ["py", "inx"]:
filenames.extend(glob.glob(os.path.join(current_dir, "*." + ext)))
# we don't want to copy setup.py
filenames.remove(os.path.join(current_dir, "setup.py"))
print("copying files\n{}\nto destination\n{}".format(filenames, dest_path))
for f in filenames:
shutil.copy2(f, dest_path)
print("done")
def package():
if not sys.platform.startswith('linux'):
print("Packaging only supported in Linux. Stopping")
return
import subprocess
cmd = ["tar", "--create", "--gzip",
"--exclude-vcs", "--exclude", "*.swp", "--exclude", "*.pyc",
"--directory", "../", "--verbose",
"--file", "../inkscape_set_css_class.tar.gz",
os.path.basename(sys.path[0])
]
print(cmd)
subprocess.call(cmd)
parser = argparse.ArgumentParser()
parser.add_argument("command", help="command to execute")
args = parser.parse_args()
if args.command == "install":
install()
elif args.command == "package":
package()