-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Should fix building with Python 3 on Mac OS X.
- Loading branch information
Showing
5 changed files
with
71 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# FindPythonLibsCustom | ||
# -------------------- | ||
# | ||
# This module locates Python libraries. | ||
# | ||
# This code sets the non-deprecated subset of the variables set by CMake's | ||
# built-in FindPythonLibs: | ||
# | ||
# PYTHONLIBS_FOUND - have the Python libs been found | ||
# PYTHON_LIBRARIES - path to the Python library | ||
# PYTHON_INCLUDE_DIRS - path to where Python.h is found | ||
# PYTHONLIBS_VERSION_STRING - version of the Python libs found | ||
# | ||
# If calling both `find_package(PythonInterp)` and | ||
# `find_package(PythonLibsCustom)`, call `find_package(PythonInterp)` first. | ||
# | ||
# Compatibility: Believed to be CMake >=2.8.8 (earlier versions of | ||
# FindPythonLibs do not provide PYTHONLIBS_VERSION_STRING). | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package(PythonInterp) | ||
if(PYTHONINTERP_FOUND) | ||
find_file(_Python_pyinfo_py pyinfo.py PATHS ${CMAKE_MODULE_PATH}) | ||
if(_Python_pyinfo_py) | ||
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${_Python_pyinfo_py} OUTPUT_VARIABLE _Python_pyinfo) | ||
unset(_Python_pyinfo_py) | ||
if(_Python_pyinfo) | ||
string(REGEX REPLACE "^.*\ninc_dir:([^\n]*)\n.*$" "\\1" PYTHON_INCLUDE_DIRS ${_Python_pyinfo}) | ||
string(REGEX REPLACE "^.*\nlib_name:([^\n]*)\n.*$" "\\1" _Python_lib_name ${_Python_pyinfo}) | ||
string(REGEX REPLACE "^.*\nlib_ver:([^\n]*)\n.*$" "\\1" PYTHONLIBS_VERSION_STRING ${_Python_pyinfo}) | ||
string(REGEX REPLACE "^.*\nlib_dir:([^\n]*)\n.*$" "\\1" _Python_lib_dir ${_Python_pyinfo}) | ||
unset(_Python_pyinfo) | ||
find_library(PYTHON_LIBRARIES NAMES ${_Python_lib_name} HINTS ${_Python_lib_dir}) | ||
unset(_Python_lib_name) | ||
unset(_Python_lib_dir) | ||
endif(_Python_pyinfo) | ||
else(_Python_pyinfo_py) | ||
message(SEND_ERROR "failed to find pyinfo.py") | ||
endif(_Python_pyinfo_py) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS PYTHONLIBS_VERSION_STRING) | ||
else(PYTHONINTERP_FOUND) | ||
message(STATUS "Python interpreter not found, falling back to FindPythonLibs") | ||
find_package(PythonLibs) | ||
endif(PYTHONINTERP_FOUND) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibsCustom DEFAULT_MSG PYTHONLIBS_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import print_function | ||
|
||
from distutils import sysconfig | ||
|
||
if __name__ == "__main__": | ||
print() | ||
print("inc_dir:%s" % sysconfig.get_python_inc()) | ||
# From testing, these interpretations of LIBRARY and LIBPL are valid for | ||
# both Python 2.7 and Python 3.5 on both Ubuntu and Mac OS X (with Homebrew | ||
# Python). | ||
lib_name = sysconfig.get_config_var("LIBRARY") | ||
if lib_name.startswith("lib"): | ||
lib_name = lib_name[3:] | ||
if lib_name.endswith(".a"): | ||
lib_name = lib_name[:-2] | ||
print("lib_name:%s" % lib_name) | ||
lib_ver = lib_name | ||
if lib_ver.startswith("python"): | ||
lib_ver = lib_ver[6:] | ||
print("lib_ver:%s" % lib_ver) | ||
print("lib_dir:%s" % sysconfig.get_config_var("LIBPL")) |