mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Closes https://github.com/caffe2/caffe2/pull/1188 Reviewed By: Yangqing Differential Revision: D5898795 Pulled By: ezyang fbshipit-source-id: 9d17c3239d8c76f6e0858a877242b6d2e11a4f18
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
## @package get_python_cmake_flags
|
|
# Module scripts.get_python_cmake_flags
|
|
##############################################################################
|
|
# Use this script to find your preferred python installation.
|
|
##############################################################################
|
|
#
|
|
# You can use the following to build with your preferred version of python
|
|
# if your installation is not being properly detected by CMake.
|
|
#
|
|
# mkdir -p build && cd build
|
|
# cmake $(python ../scripts/get_python_libs.py) ..
|
|
# make
|
|
#
|
|
|
|
from __future__ import absolute_import
|
|
from __future__ import unicode_literals
|
|
from __future__ import print_function
|
|
from distutils import sysconfig
|
|
import os
|
|
import sys
|
|
import platform
|
|
|
|
# Flags to print to stdout
|
|
flags = ''
|
|
inc = sysconfig.get_python_inc()
|
|
lib = sysconfig.get_config_var("LIBDIR")
|
|
|
|
# macOS specific
|
|
if sys.platform == "darwin":
|
|
lib = os.path.dirname(lib) + '/Python'
|
|
if os.path.isfile(lib):
|
|
flags += '-DPYTHON_LIBRARY={lib} '.format(lib=lib)
|
|
|
|
if os.path.isfile(inc + '/Python.h'):
|
|
flags += '-DPYTHON_INCLUDE_DIR={inc} '.format(inc=inc)
|
|
|
|
print(flags, end='')
|