-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·156 lines (132 loc) · 4.32 KB
/
setup.py
File metadata and controls
executable file
·156 lines (132 loc) · 4.32 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
#!/usr/bin/env python
from distutils.core import setup, Extension
DEBUG = 0
perl = 'perl'
import sys, os
from os import popen, system, access, F_OK
from os.path import isfile, getmtime
from string import split
from sys import exit
MULTI_PERL = isfile("MULTI_PERL")
BOOT_FROM_PERL = isfile("BOOT_FROM_PERL")
p = popen(perl + ' ./opts.pl')
perl_ccopts = p.readline()
perl_ldopts = p.readline()
p.close()
ext_name = "perl"
include_dirs = []
macros = []
cc_extra = []
for x in split(perl_ccopts):
if x[:2] == '-I':
include_dirs.append(x[2:])
# XXX This is disabled since distutils does not yet implement
# define_macros. Aarghhh!! So much time wasted on debugging
# because of this.
elif 0 and x[:2] == '-D':
m = split(x[2:], '=', 2)
if len(m) == 1:
m.append(None)
macros.append(tuple(m))
else:
cc_extra.append(x)
lib_dirs = []
libs = []
ld_extra = []
o_extra = []
sym_extra = []
extra_ext = []
# Hack name to get it to compile as C++ file on Windows
svrv_object_c_name = "svrv_object.c"
if sys.platform[:3] == "win":
import shutil
svrv_object_c_name = "svrv_object.cpp"
if os.path.exists(svrv_object_c_name):
os.chmod(svrv_object_c_name, 0777)
os.unlink(svrv_object_c_name)
shutil.copy("svrv_object.c", svrv_object_c_name)
sources = ['perlmodule.c',
'lang_lock.c',
'lang_map.c',
svrv_object_c_name,
'try_perlapi.c',
]
if BOOT_FROM_PERL:
cc_extra.append("-DBOOT_FROM_PERL")
else:
for x in split(perl_ldopts):
if x[:2] == '-L':
lib_dirs.append(x[2:])
elif x[:2] == '-l' and sys.platform != 'win32':
libs.append(x[2:])
elif x[:1] != '-' and (x[-3:] == '.so' or
x[-2:] == '.o' or
x[-2:] == '.a'
):
o_extra.append(x)
else:
ld_extra.append(x)
p = popen(perl + ' ./objs.pl')
objs = p.readline()
for x in split(objs):
o_extra.append(x)
p.close()
if not isfile("perlxsi.c"):
system(perl + " -MExtUtils::Embed -e xsinit")
sources.append('perlxsi.c');
# Try to figure out if we use dlopen on this platform
p = popen(perl + ' -V:dlsrc')
dlsrc = p.readline()
p.close()
if dlsrc == "dlsrc='dl_dlopen.xs';\n":
ext_name = "perl2"
cc_extra.append("-DDL_HACK")
extra_ext.append(Extension(name = "perl",
sources = ["dlhack.c"],
libraries = ["dl"],
))
if MULTI_PERL:
cc_extra.append("-DMULTI_PERL")
sources.append('thrd_ctx.c')
if not isfile("try_perlapi.c") or \
getmtime("try_perlapi.c") < getmtime("try_perlapi.pl"):
system(perl + " try_perlapi.pl")
if sys.platform == 'win32':
libs.append('perl56')
for x in ['15','16','20']:
if access(os.path.join(sys.prefix, 'libs', 'python'+x+'.lib'), \
F_OK) == 1 :
libs.append('python'+x)
sym_extra.append('get_thread_ctx')
sym_extra.append('sv2pyo')
sym_extra.append('pyo2sv')
if DEBUG:
print "Macros:", macros
print "Include: ", include_dirs
print "Extra CC: ", cc_extra
print "Obj: ", o_extra
print "Libs:", libs
print "Lib dirs:", lib_dirs
print "Extra LD: ", ld_extra
ext_modules = []
ext_modules.append(Extension(name = ext_name,
sources = sources,
define_macros = macros,
include_dirs = include_dirs,
extra_compile_args = cc_extra,
extra_objects = o_extra,
libraries = libs,
library_dirs = lib_dirs,
extra_link_args = ld_extra,
export_symbols = sym_extra,
))
ext_modules.extend(extra_ext)
setup (name = "pyperl",
version = "1.0",
description = "Embed a perl interpreter",
url = "http://www.ActiveState.com",
author = "ActiveState",
author_email= "gisle@ActiveState.com",
py_modules = ['dbi', 'dbi2', 'perlpickle', 'perlmod'],
ext_modules = ext_modules,
)