author | robin <robin@reportlab.com> |
Tue, 07 Mar 2017 10:00:34 +0000 | |
changeset 4330 | 617ffa6bbdc8 |
parent 4314 | 27d3ed39ad3e |
child 4359 | 0fbf25e48574 |
permissions | -rw-r--r-- |
4308 | 1 |
#Copyright ReportLab Europe Ltd. 2000-2017 |
2963 | 2 |
#see license.txt for license details |
4314
27d3ed39ad3e
support Image with drawing instance image; version-->3.3.30
robin <robin@reportlab.com>
parents:
4308
diff
changeset
|
3 |
__version__='3.3.30' |
3752 | 4 |
import os, sys, glob, shutil |
3974 | 5 |
def specialOption(n): |
6 |
v = False |
|
7 |
while n in sys.argv: |
|
8 |
v = True |
|
9 |
sys.argv.remove(n) |
|
10 |
return v |
|
11 |
||
12 |
#defaults for these options may be configured in local-setup.cfg |
|
13 |
#[OPTIONS] |
|
14 |
#no-download-t1-files=yes |
|
15 |
#ignore-system-libart=yes |
|
16 |
# if used on command line the config values are not used |
|
17 |
dlt1 = not specialOption('--no-download-t1-files') |
|
18 |
isla = specialOption('--ignore-system-libart') |
|
19 |
||
3752 | 20 |
try: |
21 |
import configparser |
|
22 |
except ImportError: |
|
23 |
import ConfigParser as configparser |
|
3785 | 24 |
isPy3 = sys.version_info[0]==3 |
2963 | 25 |
platform = sys.platform |
26 |
pjoin = os.path.join |
|
27 |
abspath = os.path.abspath |
|
28 |
isfile = os.path.isfile |
|
3394 | 29 |
isdir = os.path.isdir |
2963 | 30 |
dirname = os.path.dirname |
31 |
if __name__=='__main__': |
|
32 |
pkgDir=dirname(sys.argv[0]) |
|
33 |
else: |
|
34 |
pkgDir=dirname(__file__) |
|
35 |
if not pkgDir: |
|
36 |
pkgDir=os.getcwd() |
|
37 |
elif not os.path.isabs(pkgDir): |
|
38 |
pkgDir=os.path.abspath(pkgDir) |
|
3168
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
39 |
try: |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
40 |
os.chdir(pkgDir) |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
41 |
except: |
3721 | 42 |
print('!!!!! warning could not change directory to %r' % pkgDir) |
4060 | 43 |
daily=int(os.environ.get('RL_EXE_DAILY','0')) |
2963 | 44 |
|
45 |
import distutils |
|
4061 | 46 |
try: |
47 |
from setuptools import setup, Extension |
|
48 |
except ImportError: |
|
49 |
from distutils.core import setup, Extension |
|
2963 | 50 |
from distutils import sysconfig |
51 |
||
52 |
# from Zope - App.Common.package_home |
|
53 |
def package_home(globals_dict): |
|
54 |
__name__=globals_dict['__name__'] |
|
55 |
m=sys.modules[__name__] |
|
56 |
r=os.path.split(m.__path__[0])[0] |
|
57 |
return r |
|
58 |
||
59 |
package_path = pjoin(package_home(distutils.__dict__), 'site-packages', 'reportlab') |
|
60 |
||
61 |
def get_version(): |
|
3033
0c9602603837
setup.py: allow for daily builds having different version string
rgbecker
parents:
3028
diff
changeset
|
62 |
if daily: return 'daily' |
2963 | 63 |
#determine Version |
3168
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
64 |
HERE = pkgDir |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
65 |
if os.getcwd()!=HERE: |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
66 |
if __name__=='__main__': |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
67 |
HERE=os.path.dirname(sys.argv[0]) |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
68 |
else: |
cd1797023f60
setup.py: attempt to make more robust against running away from pkgDir
rgbecker
parents:
3106
diff
changeset
|
69 |
HERE=os.path.dirname(__file__) |
2963 | 70 |
|
71 |
#first try source |
|
72 |
FN = pjoin(HERE,'src','reportlab','__init__') |
|
73 |
try: |
|
74 |
for l in open(pjoin(FN+'.py'),'r').readlines(): |
|
75 |
if l.startswith('Version'): |
|
3724 | 76 |
D = {} |
77 |
exec(l.strip(),D) |
|
78 |
return D['Version'] |
|
2963 | 79 |
except: |
80 |
pass |
|
81 |
||
82 |
#don't have source, try import |
|
83 |
import imp |
|
84 |
for desc in ('.pyc', 'rb', 2), ('.pyo', 'rb', 2): |
|
85 |
try: |
|
86 |
fn = FN+desc[0] |
|
87 |
f = open(fn,desc[1]) |
|
88 |
m = imp.load_module('reportlab',f,fn,desc) |
|
89 |
return m.Version |
|
90 |
except: |
|
91 |
pass |
|
92 |
raise ValueError('Cannot determine ReportLab Version') |
|
93 |
||
94 |
class config: |
|
95 |
def __init__(self): |
|
96 |
try: |
|
3721 | 97 |
self.parser = configparser.RawConfigParser() |
3974 | 98 |
self.parser.read([pjoin(pkgDir,'setup.cfg'),pjoin(pkgDir,'local-setup.cfg')]) |
2963 | 99 |
except: |
100 |
self.parser = None |
|
101 |
||
102 |
def __call__(self,sect,name,default=None): |
|
103 |
try: |
|
104 |
return self.parser.get(sect,name) |
|
105 |
except: |
|
106 |
return default |
|
107 |
config = config() |
|
108 |
||
3974 | 109 |
if dlt1: |
110 |
#not set on command line so try for config value |
|
111 |
dlt1 = not config('OPTIONS','no-download-t1-files','0').lower() in ('1','true','yes') |
|
112 |
if not isla: |
|
113 |
#not set on command line so try for config value |
|
114 |
isla = config('OPTIONS','ignore-system-libart','0').lower() in ('1','true','yes') |
|
115 |
||
2963 | 116 |
#this code from /FBot's PIL setup.py |
117 |
def aDir(P, d, x=None): |
|
118 |
if d and os.path.isdir(d) and d not in P: |
|
119 |
if x is None: |
|
120 |
P.append(d) |
|
121 |
else: |
|
122 |
P.insert(x, d) |
|
123 |
||
124 |
class inc_lib_dirs: |
|
125 |
L = None |
|
126 |
I = None |
|
127 |
def __call__(self): |
|
128 |
if self.L is None: |
|
129 |
L = [] |
|
130 |
I = [] |
|
131 |
if platform == "cygwin": |
|
132 |
aDir(L, os.path.join("/usr/lib", "python%s" % sys.version[:3], "config")) |
|
133 |
elif platform == "darwin": |
|
134 |
# attempt to make sure we pick freetype2 over other versions |
|
135 |
aDir(I, "/sw/include/freetype2") |
|
136 |
aDir(I, "/sw/lib/freetype2/include") |
|
137 |
# fink installation directories |
|
138 |
aDir(L, "/sw/lib") |
|
139 |
aDir(I, "/sw/include") |
|
140 |
# darwin ports installation directories |
|
141 |
aDir(L, "/opt/local/lib") |
|
142 |
aDir(I, "/opt/local/include") |
|
3001 | 143 |
aDir(I, "/usr/local/include") |
2963 | 144 |
aDir(L, "/usr/local/lib") |
3102 | 145 |
aDir(I, "/usr/include") |
146 |
aDir(L, "/usr/lib") |
|
147 |
aDir(I, "/usr/include/freetype2") |
|
2963 | 148 |
prefix = sysconfig.get_config_var("prefix") |
149 |
if prefix: |
|
150 |
aDir(L, pjoin(prefix, "lib")) |
|
151 |
aDir(I, pjoin(prefix, "include")) |
|
152 |
self.L=L |
|
153 |
self.I=I |
|
154 |
return self.I,self.L |
|
155 |
inc_lib_dirs=inc_lib_dirs() |
|
156 |
||
157 |
def getVersionFromCCode(fn): |
|
158 |
import re |
|
159 |
tag = re.search(r'^#define\s+VERSION\s+"([^"]*)"',open(fn,'r').read(),re.M) |
|
160 |
return tag and tag.group(1) or '' |
|
161 |
||
162 |
class _rl_dir_info: |
|
163 |
def __init__(self,cn): |
|
164 |
self.cn=cn |
|
165 |
def __call__(self,dir): |
|
166 |
import stat |
|
167 |
fn = pjoin(dir,self.cn) |
|
168 |
try: |
|
169 |
return getVersionFromCCode(fn),os.stat(fn)[stat.ST_MTIME] |
|
170 |
except: |
|
171 |
return None |
|
172 |
||
173 |
def _find_rl_ccode(dn='rl_accel',cn='_rl_accel.c'): |
|
174 |
'''locate where the accelerator code lives''' |
|
175 |
_ = [] |
|
176 |
for x in [ |
|
177 |
pjoin('src','rl_addons',dn), |
|
178 |
pjoin('rl_addons',dn), |
|
179 |
pjoin('..','rl_addons',dn), |
|
180 |
pjoin('..','..','rl_addons',dn), |
|
181 |
dn, |
|
182 |
pjoin('..',dn), |
|
183 |
pjoin('..','..',dn), |
|
184 |
] \ |
|
185 |
+ glob.glob(pjoin(dn+'-*',dn))\ |
|
186 |
+ glob.glob(pjoin('..',dn+'-*',dn))\ |
|
187 |
+ glob.glob(pjoin('..','..',dn+'-*',dn))\ |
|
188 |
: |
|
189 |
fn = pjoin(pkgDir,x,cn) |
|
190 |
if isfile(fn): |
|
191 |
_.append(x) |
|
192 |
if _: |
|
3721 | 193 |
_ = list(filter(_rl_dir_info(cn),_)) |
2963 | 194 |
if len(_): |
3818 | 195 |
_.sort(key=_rl_dir_info) |
2963 | 196 |
return abspath(_[0]) |
197 |
return None |
|
198 |
||
199 |
||
200 |
def BIGENDIAN(macname,value=None): |
|
201 |
'define a macro if bigendian' |
|
202 |
return sys.byteorder=='big' and [(macname,value)] or [] |
|
203 |
||
204 |
def pfxJoin(pfx,*N): |
|
205 |
R=[] |
|
206 |
for n in N: |
|
207 |
R.append(os.path.join(pfx,n)) |
|
208 |
return R |
|
209 |
||
210 |
INFOLINES=[] |
|
211 |
def infoline(t): |
|
3721 | 212 |
print(t) |
2963 | 213 |
INFOLINES.append(t) |
214 |
||
2982 | 215 |
reportlab_files= [ |
2963 | 216 |
'fonts/00readme.txt', |
217 |
'fonts/bitstream-vera-license.txt', |
|
2977
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
218 |
'fonts/DarkGarden-copying-gpl.txt', |
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
219 |
'fonts/DarkGarden-copying.txt', |
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
220 |
'fonts/DarkGarden-readme.txt', |
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
221 |
'fonts/DarkGarden.sfd', |
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
222 |
'fonts/DarkGardenMK.afm', |
beca8d75f400
reportlab: remove LetErrorRobot-Chrome, rina & luxi. Add DarkGardenMK and fix tests
rgbecker
parents:
2976
diff
changeset
|
223 |
'fonts/DarkGardenMK.pfb', |
2963 | 224 |
'fonts/Vera.ttf', |
225 |
'fonts/VeraBd.ttf', |
|
226 |
'fonts/VeraBI.ttf', |
|
227 |
'fonts/VeraIt.ttf', |
|
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
228 |
'fonts/_abi____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
229 |
'fonts/_ab_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
230 |
'fonts/_ai_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
231 |
'fonts/_a______.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
232 |
'fonts/cobo____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
233 |
'fonts/cob_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
234 |
'fonts/com_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
235 |
'fonts/coo_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
236 |
'fonts/_ebi____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
237 |
'fonts/_eb_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
238 |
'fonts/_ei_____.pfb', |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
239 |
'fonts/_er_____.pfb', |
3549 | 240 |
'fonts/sy______.pfb', |
241 |
'fonts/zd______.pfb', |
|
242 |
'fonts/zx______.pfb', |
|
243 |
'fonts/zy______.pfb', |
|
2963 | 244 |
] |
245 |
||
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
246 |
def get_fonts(PACKAGE_DIR, reportlab_files): |
3785 | 247 |
import sys, os, os.path, zipfile, io |
248 |
if isPy3: |
|
249 |
import urllib.request as ureq |
|
250 |
else: |
|
251 |
import urllib2 as ureq |
|
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
252 |
rl_dir = PACKAGE_DIR['reportlab'] |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
253 |
if not [x for x in reportlab_files if not os.path.isfile(pjoin(rl_dir,x))]: |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
254 |
infoline("Standard T1 font curves already downloaded") |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
255 |
return |
3974 | 256 |
elif not dlt1: |
257 |
infoline('not downloading T1 font curve files') |
|
258 |
return |
|
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
259 |
try: |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
260 |
infoline("Downloading standard T1 font curves") |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
261 |
|
3785 | 262 |
remotehandle = ureq.urlopen("http://www.reportlab.com/ftp/pfbfer-20070710.zip") |
3764 | 263 |
zipdata = io.BytesIO(remotehandle.read()) |
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
264 |
remotehandle.close() |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
265 |
archive = zipfile.ZipFile(zipdata) |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
266 |
dst = pjoin(rl_dir, 'fonts') |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
267 |
|
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
268 |
for name in archive.namelist(): |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
269 |
if not name.endswith('/'): |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
270 |
outfile = open(os.path.join(dst, name), 'wb') |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
271 |
outfile.write(archive.read(name)) |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
272 |
outfile.close() |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
273 |
xitmsg = "Finished download of standard T1 font curves" |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
274 |
except: |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
275 |
xitmsg = "Failed to download standard T1 font curves" |
3328 | 276 |
reportlab_files = [x for x in reportlab_files if os.path.isfile(pjoin(rl_dir,x))] |
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
277 |
infoline(xitmsg) |
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
278 |
|
2963 | 279 |
def main(): |
280 |
#test to see if we've a special command |
|
281 |
if 'tests' in sys.argv or 'tests-preinstall' in sys.argv: |
|
282 |
if len(sys.argv)!=2: |
|
283 |
raise ValueError('tests commands may only be used alone') |
|
284 |
cmd = sys.argv[-1] |
|
285 |
PYTHONPATH=[pkgDir] |
|
286 |
if cmd=='tests-preinstall': |
|
287 |
PYTHONPATH.insert(0,pjoin(pkgDir,'src')) |
|
288 |
os.environ['PYTHONPATH']=os.pathsep.join(PYTHONPATH) |
|
289 |
os.chdir(pjoin(pkgDir,'tests')) |
|
290 |
os.system("%s runAll.py" % sys.executable) |
|
291 |
return |
|
292 |
||
3878 | 293 |
debug_compile_args = [] |
294 |
debug_link_args = [] |
|
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
295 |
debug_macros = [] |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
296 |
debug = int(os.environ.get('RL_DEBUG','0')) |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
297 |
if debug: |
3878 | 298 |
if sys.platform == 'win32': |
299 |
debug_compile_args=['/Zi'] |
|
300 |
debug_link_args=['/DEBUG'] |
|
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
301 |
if debug>1: |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
302 |
debug_macros.extend([('RL_DEBUG',debug), ('ROBIN_DEBUG',None)]) |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
303 |
|
2982 | 304 |
SPECIAL_PACKAGE_DATA = {} |
2963 | 305 |
RL_ACCEL = _find_rl_ccode('rl_accel','_rl_accel.c') |
306 |
LIBRARIES=[] |
|
307 |
EXT_MODULES = [] |
|
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
308 |
|
2963 | 309 |
if not RL_ACCEL: |
4308 | 310 |
infoline( '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
311 |
infoline( 'not attempting build of the _rl_accel extension') |
|
312 |
infoline( '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
|
2963 | 313 |
else: |
4308 | 314 |
infoline( '================================================') |
315 |
infoline( 'Attempting build of _rl_accel & pyHnj') |
|
316 |
infoline( 'extensions from %r'%RL_ACCEL) |
|
317 |
infoline( '================================================') |
|
2982 | 318 |
fn = pjoin(RL_ACCEL,'hyphen.mashed') |
319 |
SPECIAL_PACKAGE_DATA = {fn: pjoin('lib','hyphen.mashed')} |
|
2963 | 320 |
EXT_MODULES += [ |
3727
67e69a84138b
changes to bring into line with new Python 3.3.0 universe
robin
parents:
3724
diff
changeset
|
321 |
Extension( 'reportlab.lib._rl_accel', |
2963 | 322 |
[pjoin(RL_ACCEL,'_rl_accel.c')], |
323 |
include_dirs=[], |
|
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
324 |
define_macros=[]+debug_macros, |
2963 | 325 |
library_dirs=[], |
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
326 |
libraries=[], # libraries to link against |
3878 | 327 |
extra_compile_args=debug_compile_args, |
328 |
extra_link_args=debug_link_args, |
|
2963 | 329 |
), |
3733 | 330 |
] |
3785 | 331 |
if not isPy3: |
3733 | 332 |
EXT_MODULES += [ |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
333 |
Extension( 'reportlab.lib.pyHnj', |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
334 |
[pjoin(RL_ACCEL,'pyHnjmodule.c'), |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
335 |
pjoin(RL_ACCEL,'hyphen.c'), |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
336 |
pjoin(RL_ACCEL,'hnjalloc.c')], |
2963 | 337 |
include_dirs=[], |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
338 |
define_macros=[]+debug_macros, |
2963 | 339 |
library_dirs=[], |
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
340 |
libraries=[], # libraries to link against |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
341 |
extra_compile_args=debug_compile_args, |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
342 |
extra_link_args=debug_link_args, |
2963 | 343 |
), |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
344 |
] |
2963 | 345 |
RENDERPM = _find_rl_ccode('renderPM','_renderPM.c') |
346 |
if not RENDERPM: |
|
347 |
infoline( '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
|
4308 | 348 |
infoline( 'not attempting build of _renderPM') |
2963 | 349 |
infoline( '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
350 |
else: |
|
4308 | 351 |
infoline( '================================================') |
352 |
infoline( 'Attempting build of _renderPM') |
|
353 |
infoline( 'extensions from %r'%RENDERPM) |
|
354 |
infoline( '================================================') |
|
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
355 |
GT1_DIR=pjoin(RENDERPM,'gt1') |
3974 | 356 |
|
357 |
#check for an installed libart |
|
358 |
if isla: |
|
359 |
LIBART_INC=None |
|
360 |
else: |
|
361 |
LIBART_INC = list(sorted(glob.glob('/usr/include/libart-*/libart_lgpl/libart-features.h'))) |
|
362 |
if LIBART_INC: |
|
363 |
def installed_libart_version(fn): |
|
364 |
for l in open(fn, 'r').readlines(): |
|
365 |
if l.startswith('#define LIBART_VERSION'): |
|
366 |
v = l[:-1].split(' ')[-1] |
|
367 |
return v |
|
368 |
return '"0.0.0"' |
|
369 |
LIBART_INC = LIBART_INC[-1] |
|
370 |
LIBART_VERSION = installed_libart_version(LIBART_INC) |
|
371 |
LIBART_INC = os.path.dirname(LIBART_INC) |
|
372 |
LIBART_SOURCES=[] |
|
373 |
LIBART_LIB = ['art_lgpl_2'] |
|
374 |
infoline('will use installed libart %s' % LIBART_VERSION.replace('"','')) |
|
375 |
else: |
|
376 |
LIBART_DIR = LIBART_INC = pjoin(RENDERPM,'libart_lgpl') |
|
377 |
LIBART_LIB = [] |
|
378 |
LIBART_SOURCES=[ |
|
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
379 |
pjoin(LIBART_DIR,'art_vpath_bpath.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
380 |
pjoin(LIBART_DIR,'art_rgb_pixbuf_affine.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
381 |
pjoin(LIBART_DIR,'art_rgb_svp.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
382 |
pjoin(LIBART_DIR,'art_svp.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
383 |
pjoin(LIBART_DIR,'art_svp_vpath.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
384 |
pjoin(LIBART_DIR,'art_svp_vpath_stroke.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
385 |
pjoin(LIBART_DIR,'art_svp_ops.c'), |
4306
8ffb2ffc283b
support for Path autoclose & fillMode; version --> 3.3.29
robin
parents:
4303
diff
changeset
|
386 |
pjoin(LIBART_DIR,'art_svp_wind.c'), |
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
387 |
pjoin(LIBART_DIR,'art_vpath.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
388 |
pjoin(LIBART_DIR,'art_vpath_dash.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
389 |
pjoin(LIBART_DIR,'art_affine.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
390 |
pjoin(LIBART_DIR,'art_rect.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
391 |
pjoin(LIBART_DIR,'art_rgb_affine.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
392 |
pjoin(LIBART_DIR,'art_rgb_affine_private.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
393 |
pjoin(LIBART_DIR,'art_rgb.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
394 |
pjoin(LIBART_DIR,'art_rgb_rgba_affine.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
395 |
pjoin(LIBART_DIR,'art_svp_intersect.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
396 |
pjoin(LIBART_DIR,'art_svp_render_aa.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
397 |
pjoin(LIBART_DIR,'art_misc.c'), |
3974 | 398 |
] |
399 |
def libart_version(): |
|
400 |
K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') |
|
401 |
D = {} |
|
402 |
for l in open(pjoin(LIBART_DIR,'configure.in'),'r').readlines(): |
|
403 |
l = l.strip().split('=') |
|
404 |
if len(l)>1 and l[0].strip() in K: |
|
405 |
D[l[0].strip()] = l[1].strip() |
|
406 |
if len(D)==3: break |
|
407 |
return (sys.platform == 'win32' and '\\"%s\\"' or '"%s"') % '.'.join(map(lambda k,D=D: D.get(k,'?'),K)) |
|
408 |
LIBART_VERSION = libart_version() |
|
409 |
infoline('will use package libart %s' % LIBART_VERSION.replace('"','')) |
|
410 |
||
411 |
SOURCES=[pjoin(RENDERPM,'_renderPM.c'), |
|
3278
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
412 |
pjoin(GT1_DIR,'gt1-parset1.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
413 |
pjoin(GT1_DIR,'gt1-dict.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
414 |
pjoin(GT1_DIR,'gt1-namecontext.c'), |
ce6c49bb9dc3
setup.py modified to work with easy_install (C extensions referred to explicitly)
damian
parents:
3168
diff
changeset
|
415 |
pjoin(GT1_DIR,'gt1-region.c'), |
3974 | 416 |
]+LIBART_SOURCES |
2963 | 417 |
|
418 |
if platform=='win32': |
|
4142
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
419 |
from distutils.util import get_platform |
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
420 |
secname = 'FREETYPE_PATHS_%s' % get_platform().split('-')[-1].upper() |
3396 | 421 |
FT_LIB=os.environ.get('FT_LIB','') |
4142
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
422 |
if not FT_LIB: FT_LIB=config(secname,'lib','') |
3301 | 423 |
if FT_LIB and not os.path.isfile(FT_LIB): |
424 |
infoline('# freetype lib %r not found' % FT_LIB) |
|
425 |
FT_LIB=[] |
|
2963 | 426 |
if FT_LIB: |
3396 | 427 |
FT_INC_DIR=os.environ.get('FT_INC','') |
4142
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
428 |
if not FT_INC_DIR: FT_INC_DIR=config(secname,'inc') |
2963 | 429 |
FT_MACROS = [('RENDERPM_FT',None)] |
430 |
FT_LIB_DIR = [dirname(FT_LIB)] |
|
431 |
FT_INC_DIR = [FT_INC_DIR or pjoin(dirname(FT_LIB_DIR[0]),'include')] |
|
3352
753cbc1ed53f
setup.py: allow win32 FT libs to come from the environment
rgbecker
parents:
3328
diff
changeset
|
432 |
FT_LIB_PATH = FT_LIB |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
433 |
FT_LIB = [os.path.splitext(os.path.basename(FT_LIB))[0]] |
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
434 |
if isdir(FT_INC_DIR[0]): |
3352
753cbc1ed53f
setup.py: allow win32 FT libs to come from the environment
rgbecker
parents:
3328
diff
changeset
|
435 |
infoline('# installing with freetype %r' % FT_LIB_PATH) |
3301 | 436 |
else: |
437 |
infoline('# freetype2 include folder %r not found' % FT_INC_DIR[0]) |
|
438 |
FT_LIB=FT_LIB_DIR=FT_INC_DIR=FT_MACROS=[] |
|
2963 | 439 |
else: |
440 |
FT_LIB=FT_LIB_DIR=FT_INC_DIR=FT_MACROS=[] |
|
441 |
else: |
|
3974 | 442 |
if os.path.isdir('/usr/include/freetype2'): |
443 |
FT_LIB_DIR = [] |
|
444 |
FT_INC_DIR = ['/usr/include/freetype2'] |
|
445 |
else: |
|
4142
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
446 |
FT_LIB_DIR=config('FREETYPE_PATHS','lib') |
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
447 |
FT_LIB_DIR=[FT_LIB_DIR] if FT_LIB_DIR else [] |
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
448 |
FT_INC_DIR=config('FREETYPE_PATHS','inc') |
099ebb771226
change setup.py & setup.cfg to reflect building on windows 7 amd64 machine; bump to 3.1.39
robin
parents:
4079
diff
changeset
|
449 |
FT_INC_DIR=[FT_INC_DIR] if FT_INC_DIR else [] |
2963 | 450 |
I,L=inc_lib_dirs() |
451 |
ftv = None |
|
452 |
for d in I: |
|
453 |
if isfile(pjoin(d, "ft2build.h")): |
|
454 |
ftv = 21 |
|
2976
8275469b0747
setup.py: now works on freeBSD; how _rl_accel_dir_info ever got by I know not
rptlab
parents:
2963
diff
changeset
|
455 |
FT_INC_DIR=[d,pjoin(d, "freetype2")] |
2963 | 456 |
break |
457 |
d = pjoin(d, "freetype2") |
|
458 |
if isfile(pjoin(d, "ft2build.h")): |
|
459 |
ftv = 21 |
|
2976
8275469b0747
setup.py: now works on freeBSD; how _rl_accel_dir_info ever got by I know not
rptlab
parents:
2963
diff
changeset
|
460 |
FT_INC_DIR=[d] |
2963 | 461 |
break |
462 |
if isdir(pjoin(d, "freetype")): |
|
463 |
ftv = 20 |
|
2976
8275469b0747
setup.py: now works on freeBSD; how _rl_accel_dir_info ever got by I know not
rptlab
parents:
2963
diff
changeset
|
464 |
FT_INC_DIR=[d] |
2963 | 465 |
break |
466 |
if ftv: |
|
467 |
FT_LIB=['freetype'] |
|
468 |
FT_LIB_DIR=L |
|
469 |
FT_MACROS = [('RENDERPM_FT',None)] |
|
470 |
infoline('# installing with freetype version %d' % ftv) |
|
471 |
else: |
|
472 |
FT_LIB=FT_LIB_DIR=FT_INC_DIR=FT_MACROS=[] |
|
473 |
if not FT_LIB: |
|
474 |
infoline('# installing without freetype no ttf, sorry!') |
|
3301 | 475 |
infoline('# You need to install a static library version of the freetype2 software') |
476 |
infoline('# If you need truetype support in renderPM') |
|
477 |
infoline('# You may need to edit setup.cfg (win32)') |
|
478 |
infoline('# or edit this file to access the library if it is installed') |
|
3878 | 479 |
|
3727
67e69a84138b
changes to bring into line with new Python 3.3.0 universe
robin
parents:
3724
diff
changeset
|
480 |
EXT_MODULES += [Extension( 'reportlab.graphics._renderPM', |
2963 | 481 |
SOURCES, |
3974 | 482 |
include_dirs=[RENDERPM,LIBART_INC,GT1_DIR]+FT_INC_DIR, |
3943
0e897efde30f
sgmlop.c: allow compilation in Python 3.3 & 2.7, with new returnUnicode option as default
robin
parents:
3878
diff
changeset
|
483 |
define_macros=FT_MACROS+[('LIBART_COMPILATION',None)]+debug_macros+[('LIBART_VERSION',LIBART_VERSION)], |
2963 | 484 |
library_dirs=[]+FT_LIB_DIR, |
485 |
||
486 |
# libraries to link against |
|
3974 | 487 |
libraries=FT_LIB+LIBART_LIB, |
3878 | 488 |
extra_compile_args=debug_compile_args, |
489 |
extra_link_args=debug_link_args, |
|
2963 | 490 |
), |
491 |
] |
|
492 |
infoline('################################################') |
|
493 |
||
2982 | 494 |
#copy some special case files into place so package_data will treat them properly |
4157
dc2894478c0d
setup.py: fix for pip -e proposed by Marius Gedminas
robin
parents:
4142
diff
changeset
|
495 |
PACKAGE_DIR = {'':'src','reportlab': pjoin('src','reportlab')} |
3721 | 496 |
for fn,dst in SPECIAL_PACKAGE_DATA.items(): |
2982 | 497 |
shutil.copyfile(fn,pjoin(PACKAGE_DIR['reportlab'],dst)) |
498 |
reportlab_files.append(dst) |
|
3285
af395f8ca4a2
setup.py now downloads T1 font curves when using easy_install or distutils
damian
parents:
3278
diff
changeset
|
499 |
get_fonts(PACKAGE_DIR, reportlab_files) |
2982 | 500 |
try: |
501 |
setup( |
|
2963 | 502 |
name="reportlab", |
503 |
version=get_version(), |
|
4208 | 504 |
license="BSD license (see license.txt for details), Copyright (c) 2000-2015, ReportLab Inc.", |
2963 | 505 |
description="The Reportlab Toolkit", |
2982 | 506 |
long_description="""The ReportLab Toolkit. An Open Source Python library for generating PDFs and graphics.""", |
2963 | 507 |
|
3303 | 508 |
author="Andy Robinson, Robin Becker, the ReportLab team and the community", |
509 |
author_email="reportlab-users@lists2.reportlab.com", |
|
2963 | 510 |
url="http://www.reportlab.com/", |
2982 | 511 |
packages=[ |
2963 | 512 |
'reportlab', |
513 |
'reportlab.graphics.charts', |
|
514 |
'reportlab.graphics.samples', |
|
515 |
'reportlab.graphics.widgets', |
|
516 |
'reportlab.graphics.barcode', |
|
517 |
'reportlab.graphics', |
|
518 |
'reportlab.lib', |
|
519 |
'reportlab.pdfbase', |
|
520 |
'reportlab.pdfgen', |
|
521 |
'reportlab.platypus', |
|
2982 | 522 |
], |
523 |
package_dir = PACKAGE_DIR, |
|
524 |
package_data = {'reportlab': reportlab_files}, |
|
2963 | 525 |
ext_modules = EXT_MODULES, |
4225
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
526 |
classifiers = [ |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
527 |
'Development Status :: 5 - Production/Stable', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
528 |
'Intended Audience :: Developers', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
529 |
'License :: OSI Approved :: BSD License', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
530 |
'Topic :: Printing', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
531 |
'Topic :: Text Processing :: Markup', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
532 |
'Programming Language :: Python :: 2', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
533 |
'Programming Language :: Python :: 2.7', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
534 |
'Programming Language :: Python :: 3', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
535 |
'Programming Language :: Python :: 3.3', |
bc6ca1679f8f
setup.py: apply classifiers as suggested by https://bitbucket.org/pmdarrow/
robin
parents:
4208
diff
changeset
|
536 |
'Programming Language :: Python :: 3.4', |
4282
d3a68f4690c2
add 3.5 in setup.py, update licencse, version-->3.3.15
robin
parents:
4252
diff
changeset
|
537 |
'Programming Language :: Python :: 3.5', |
4330 | 538 |
'Programming Language :: Python :: 3.6', |
4226 | 539 |
], |
4061 | 540 |
|
541 |
#this probably only works for setuptools, but distutils seems to ignore it |
|
4079
4df3c1696c1b
setup.py: pillow >=2.4.0 only (fixes buildout failure), bump version to 3.1.9
robin
parents:
4072
diff
changeset
|
542 |
install_requires=['pillow>=2.4.0','pip>=1.4.1', 'setuptools>=2.2'], |
2982 | 543 |
) |
3721 | 544 |
print() |
545 |
print('########## SUMMARY INFO #########') |
|
546 |
print('\n'.join(INFOLINES)) |
|
2982 | 547 |
finally: |
3721 | 548 |
for dst in SPECIAL_PACKAGE_DATA.values(): |
2982 | 549 |
os.remove(pjoin(PACKAGE_DIR['reportlab'],dst)) |
550 |
reportlab_files.remove(dst) |
|
2963 | 551 |
|
552 |
if __name__=='__main__': |
|
553 |
main() |