Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
207 lines (183 loc) · 6.79 KB
/
Copy pathsetup.py
File metadata and controls
207 lines (183 loc) · 6.79 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import io
import os
import platform
import subprocess
import sys
import time
from distutils.util import get_platform
import setuptools.command.build_py
from setuptools import setup, find_packages
"""
Notes:
In order to upolad the afdko wheel to testpypi to test the package, I had to
first update the Mac OSX system python ssl module with 'pip install pyOpenSSL
ndg-httpsclient pyasn1'. Otherwise, the command 'twine upload --repository-url
https://test.pypi.org/legacy/ dist/*' would fail with
'SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION]'
"""
"""
We need a customized version of the 'bdist_wheel' command, because otherwise
the wheel is identified as being non-platform specific. This is because the
afdko has no Python extensions and the command line tools are installed as
data files.
"""
try:
from wheel.bdist_wheel import bdist_wheel
# noinspection PyClassicStyleClass,PyAttributeOutsideInit
class CustomBDistWheel(bdist_wheel):
def finalize_options(self):
# noinspection PyArgumentList
bdist_wheel.finalize_options(self)
self.root_is_pure = False
except ImportError:
print("setup requires that the Python package 'wheel' be installed. "
"Try the command 'pip install wheel'.")
sys.exit(1)
def get_executable_dir():
"""
Build source path on the afdko for the command-line tools.
"""
platform_system = platform.system()
if platform_system == "Windows":
bin_dir = "win"
elif platform_system == "Linux":
bin_dir = "linux"
elif platform_system == "Darwin":
bin_dir = "osx"
else:
raise KeyError(
"Do not recognize target OS: {}".format(platform_system))
return bin_dir
def compile_package(pkg_dir):
bin_dir = get_executable_dir()
programs_dir = os.path.join(pkg_dir, "Tools", "Programs")
cmd = None
if bin_dir == 'osx':
cmd = "sh BuildAll.sh"
elif bin_dir == 'win':
cmd = "BuildAll.cmd"
elif bin_dir == 'linux':
cmd = "sh BuildAllLinux.sh"
cur_dir = os.getcwd()
assert cmd, 'Unable to form build command for this platform.'
try:
subprocess.check_call(cmd, cwd=programs_dir, shell=True)
except subprocess.CalledProcessError:
print('Error executing build command.')
sys.exit(1)
os.chdir(cur_dir)
# noinspection PyClassicStyleClass
class CustomBuild(setuptools.command.build_py.build_py):
"""Custom build command."""
def run(self):
pkg_dir = 'afdko'
compile_package(pkg_dir)
setuptools.command.build_py.build_py.run(self)
def get_scripts():
bin_dir = get_executable_dir()
script_names = [
'autohintexe', 'detype1', 'makeotfexe', 'mergeFonts', 'rotateFont',
'sfntdiff', 'sfntedit', 'spot', 'tx', 'type1'
]
if platform.system() == 'Windows':
extension = '.exe'
else:
extension = ''
scripts = ['afdko/Tools/{}/{}{}'.format(bin_dir, script_name, extension)
for script_name in script_names]
return scripts
def get_console_scripts():
script_entries = [
('autohint', 'autohint:main'),
('buildcff2vf', 'buildCFF2VF:run'),
('buildmasterotfs', 'buildMasterOTFs:main'),
('comparefamily', 'CompareFamily:main'),
('checkoutlinesufo', 'CheckOutlinesUFO:main'),
('copycffcharstrings', 'copyCFFCharstrings:run'),
('kerncheck', 'kernCheck:run'),
('makeotf', 'MakeOTF:main'),
('makeinstances', 'makeInstances:main'),
('makeinstancesufo', 'makeInstancesUFO:main'),
('otc2otf', 'otc2otf:main'),
('otf2otc', 'otf2otc:main'),
('stemhist', 'StemHist:main'),
('ttfcomponentizer', 'ttfcomponentizer:main'),
('ttxn', 'ttxn:main'),
('charplot', 'ProofPDF:charplot'),
('digiplot', 'ProofPDF:digiplot'),
('fontplot', 'ProofPDF:fontplot'),
('fontplot2', 'ProofPDF:fontplot2'),
('fontsetplot', 'ProofPDF:fontsetplot'),
('hintplot', 'ProofPDF:hintplot'),
('waterfallplot', 'ProofPDF:waterfallplot'),
('clean_afdko', 'FDKUtils:clean_afdko'),
('check_afdko', 'FDKUtils:check_afdko')
]
scripts_path = 'afdko.Tools.SharedData.FDKScripts'
scripts = ['{} = {}.{}'.format(name, scripts_path, entry)
for name, entry in script_entries]
return scripts
def main():
pkg_list = find_packages()
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
]
scripts = get_scripts()
console_scripts = get_console_scripts()
platform_system = platform.system()
if platform_system == "Darwin":
more_keywords = ['Operating System :: MacOS :: MacOS X']
elif platform_system == "Windows":
more_keywords = ['Operating System :: Microsoft :: Windows']
elif platform_system == "Linux":
more_keywords = ['Operating System :: POSIX :: Linux']
else:
raise KeyError(
"Do not recognize target OS: {}".format(platform_system))
classifiers.extend(more_keywords)
# concatenate README.rst and NEWS.rest into long_description so they are
# displayed on the afdko project page on PyPI
# Copied from fonttools setup.py
with io.open("README.rst", encoding="utf-8") as readme:
long_description = readme.read()
with io.open("NEWS.rst", encoding="utf-8") as changelog:
long_description += changelog.read()
platform_name = get_platform()
setup(name="afdko",
version="2.6.26.dev" + time.strftime("%Y%m%d%H%M%S"),
description="Adobe Font Development Kit for OpenType",
long_description=long_description,
url='https://github.com/adobe-type-tools/afdko',
author='Adobe Type team & friends',
author_email='afdko@adobe.com',
license='Apache License, Version 2.0',
classifiers=classifiers,
keywords='font development tools',
platforms=[platform_name],
packages=pkg_list,
include_package_data=True,
zip_safe=False,
python_requires='>=2.7',
setup_requires=['wheel'],
install_requires=[
'fonttools>=3.19.0',
'booleanOperations>=0.7.1',
'fontMath>=0.4.4',
'defcon>=0.3.5',
'mutatorMath>=2.1.0',
'ufolib>=2.1.1',
'ufonormalizer>=0.3.2',
'fontPens>=0.1.0'
],
scripts=scripts,
entry_points={
'console_scripts': console_scripts,
},
cmdclass={'build_py': CustomBuild, 'bdist_wheel': CustomBDistWheel},
)
if __name__ == '__main__':
main()