44from subprocess import check_call
55import sys
66
7- SCRIPT_DIR = os .path .dirname (__file__ )
7+ SCRIPT_DIR = os .path .abspath ( os . path . dirname (__file__ ) )
88ROOT_DIR = os .path .abspath (os .path .join (SCRIPT_DIR , ".." ))
99STANDALONE_DIR = os .path .join (ROOT_DIR , "standalone-build" )
1010PROJECT_NAME = "VTK"
1111
1212
13+ def get_dummy_python_lib ():
14+ """Since the python interpreter exports its symbol (see [1]), python modules
15+ should not link against any python libraries. To ensure it is not the case,
16+ we configure the project using an empty file as python library.
17+
18+ [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that a
19+ manylinux1 extension is allowed to link to. Explicitly linking to
20+ libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking
21+ works, extension modules that are loaded into the interpreter automatically
22+ get access to all of the interpreter's symbols, regardless of whether or
23+ not the extension itself is explicitly linked against libpython. [...]"
24+
25+ Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
26+
27+ """
28+ py_lib = os .path .join (
29+ SCRIPT_DIR , 'internal' ,
30+ 'libpython-not-needed-symbols-exported-by-interpreter'
31+ )
32+
33+ if not os .path .exists (py_lib ):
34+ with open (py_lib , 'w' ) as fp :
35+ fp .write ('' )
36+ return py_lib
37+
38+
1339def get_python_info ():
1440 py_exe = sys .executable
1541 version = sys .version_info [:2 ]
1642 py_ver = '{0}.{1}' .format (* version )
1743 prefix = os .path .abspath (sys .prefix )
1844 py_inc_dir = glob .glob (os .path .join (prefix , 'include' , 'python*' ))[0 ]
1945 py_lib_dir = os .path .join (prefix , 'lib' )
20- py_lib = os . path . join ( py_lib_dir , 'libpython%s.dylib' % py_ver )
46+ py_lib = get_dummy_python_lib ( )
2147 return py_exe , py_ver , py_inc_dir , py_lib
2248
2349
@@ -26,6 +52,7 @@ def build_wheel(cleanup=False):
2652 build_type = 'Release'
2753 source_path = "%s/%s-source" % (STANDALONE_DIR , PROJECT_NAME )
2854 build_path = "%s/%s-osx_%s" % (ROOT_DIR , PROJECT_NAME , py_ver )
55+ osx_target = "10.9"
2956
3057 # Clean up previous invocations
3158 if cleanup and os .path .exists (build_path ):
@@ -44,6 +71,7 @@ def build_wheel(cleanup=False):
4471 "--" ,
4572 "-DVTK_SOURCE_DIR:PATH=%s" % source_path ,
4673 "-DVTK_BINARY_DIR:PATH=%s" % build_path ,
74+ "-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=%s" % osx_target ,
4775 "-DPYTHON_EXECUTABLE:FILEPATH=%s" % py_exe ,
4876 "-DPYTHON_INCLUDE_DIR:PATH=%s" % py_inc_dir ,
4977 "-DPYTHON_LIBRARY:FILEPATH=%s" % py_lib
@@ -59,4 +87,3 @@ def main():
5987
6088if __name__ == '__main__' :
6189 main ()
62-
0 commit comments