Skip to content

Commit 1f7d851

Browse files
BUG/ENH: Fix several issues pointed out.
- Specify the OSX_DEPLOYMENT_TARGET to 10.9. - Do not link to the actual libpython and instead create a dummy file that is used for linking. - Correctly set the VTK_USE_X flag on APPLE and WIN32.
1 parent b4be3da commit 1f7d851

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if(VTKPythonPackage_SUPERBUILD)
6363

6464
option(VTK_OPENGL_HAS_OSMESA "Use OSMesa for offscreen rendering" OFF)
6565
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)
66-
if(VTK_OPENGL_HAS_OSMESA)
66+
if(VTK_OPENGL_HAS_OSMESA OR APPLE OR WIN32)
6767
set(VTK_USE_X OFF)
6868
else()
6969
set(VTK_USE_X ON)

‎scripts/macos_build_wheel.py‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,46 @@
44
from subprocess import check_call
55
import sys
66

7-
SCRIPT_DIR = os.path.dirname(__file__)
7+
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
88
ROOT_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
99
STANDALONE_DIR = os.path.join(ROOT_DIR, "standalone-build")
1010
PROJECT_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+
1339
def 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

6088
if __name__ == '__main__':
6189
main()
62-

0 commit comments

Comments
 (0)