forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_package.py
More file actions
54 lines (46 loc) · 1.68 KB
/
Copy pathsetup_package.py
File metadata and controls
54 lines (46 loc) · 1.68 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
from distutils.core import Extension
from os.path import join
import sys
from astropy import setup_helpers
def get_external_libraries():
return ['expat']
def get_extensions(build_type='release'):
XML_DIR = 'astropy/utils/xml/src'
source_files = [join(XML_DIR, "iterparse.c")]
include_dirs = []
extra_link_args = []
defines = []
libraries = []
library_dirs = []
if setup_helpers.use_system_library('expat'):
setup_helpers.pkg_config(
['expat'], ['expat'], include_dirs, library_dirs, libraries)
else:
EXPAT_DIR = 'cextern/expat/lib'
source_files.extend([
join(EXPAT_DIR, fn) for fn in
["xmlparse.c", "xmlrole.c", "xmltok.c", "xmltok_impl.c"]])
include_dirs.extend([XML_DIR, EXPAT_DIR])
if sys.platform.startswith('linux'):
# This is to ensure we only export the Python entry point
# symbols and the linker won't try to use the system expat in
# place of ours.
extra_link_args.append(
'-Wl,--version-script={0}'.format(
join(XML_DIR, 'iterparse.map'))
)
defines = [("HAVE_EXPAT_CONFIG_H", 1)]
if sys.byteorder == 'big':
defines.append(('BYTEORDER', '4321'))
else:
defines.append(('BYTEORDER', '1234'))
if sys.platform != 'win32':
defines.append(('HAVE_UNISTD_H', None))
return [Extension(
"astropy.utils.xml._iterparser",
source_files,
define_macros=defines,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_link_args=extra_link_args)]