-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
122 lines (86 loc) · 2.92 KB
/
build.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
120
121
122
# """build RoboFont StemPlow Extension"""
import os
import tomllib
from pathlib import Path
from mojo.extensions import ExtensionBundle # type: ignore
def getVersionFromPyProject():
pyprojectPath = Path(__file__).parent / "pyproject.toml"
pyProjectMetadata = tomllib.loads(pyprojectPath.read_text(encoding="utf-8"))
return pyProjectMetadata["tool"]["poetry"]["version"]
__version__ = getVersionFromPyProject()
def exec_cmd(cmd):
import subprocess
import shlex
import traceback
try:
subprocess.check_call(shlex.split(cmd))
except:
print(f"issue with cmd\n\t${cmd}")
print(traceback.format_exc())
name = "Stem Plow"
# get current folder
basePath = os.path.dirname(__file__)
# source folder for all extension files
sourcePath = os.path.join(basePath, "source")
# folder with python files
libPath = os.path.join(sourcePath, "code")
# # folder with html files
htmlPath = os.path.join(sourcePath, "documentation")
# htmlPath = None
# # folder with resources (icons etc)
# resourcesPath = os.path.join(sourcePath, 'resources')
resourcesPath = None
# load license text from file
# see choosealicense.com for more open-source licenses
licensePath = os.path.join(basePath, "licence.txt")
# boolean indicating if only .pyc should be included
pycOnly = False
# name of the compiled extension file
extensionFile = f'{name.replace(" ","")}.roboFontExt'
# path of the compiled extension
buildPath = os.path.join(basePath, "build")
extensionPath = os.path.join(buildPath, extensionFile)
# initiate the extension builder
B = ExtensionBundle()
# scripts which should appear in Extensions menu
B.addToMenu = [
{
"path": "stemPlow/StemPlowSettings.py",
"preferredName": "Settings…",
"shortKey": "",
}
]
# name of the extension
B.name = name
# name of the developer
B.developer = "Rafał Buchner"
# URL of the developer
B.developerURL = "http://github.com/rafalbuchner"
# # extension icon (file path or NSImage)
# imagePath = os.path.join(resourcesPath, 'icon.png')
# B.icon = imagePath
# version of the extension
B.version = __version__
# should the extension be launched at start-up?
B.launchAtStartUp = True
# script to be executed when RF starts
B.mainScript = "StemPlowTool.py"
# does the extension contain html help files?
B.html = True
# minimum RoboFont version required for this extension
B.requiresVersionMajor = "4"
B.requiresVersionMinor = "2"
# license for the extension
with open(licensePath, encoding="utf-8") as license:
B.license = license.read()
# # expiration date for trial extensions
# B.expireDate = '2019-12-31'
# compile and save the extension bundle
print(f"building extension {B.name} version {__version__}...", end=" ")
B.save(extensionPath, libPath=libPath, htmlPath=htmlPath, resourcesPath=resourcesPath)
print("done!")
# check for problems in the compiled extension
print()
print(B.validationErrors())
if "" == str(B.validationErrors()):
B.install()