📄 python.jam
字号:
if ! $(gPYTHON_INCLUDED)
{
gPYTHON_INCLUDED = true ;
import testing ;
# Do some OS-specific setup
if $(NT)
{
CATENATE = type ;
}
else if $(UNIX)
{
CATENATE = cat ;
}
PYTHON_VERSION ?= 2.4 ;
# Strip the dot from the Python version in order to be able to name
# libraries
PYTHON_VERSION_NODOT
= [ MATCH ([0-9]*)\.([0-9]*) : $(PYTHON_VERSION) ]
;
PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT:J=) ;
local RUN_PATH = $(RUN_PATH) ;
if $(NT) || ( $(UNIX) && $(OS) = CYGWIN )
{
PYTHON_WINDOWS = true ;
}
if $(PYTHON_WINDOWS)
{
# common properties required for compiling any Python module.
PYTHON_PROPERTIES =
boost-python-disable-borland
select-nt-python-includes
<runtime-link>dynamic
<sysinclude>@boost
<$(gcc-compilers)><*><define>USE_DL_IMPORT
;
CYGWIN_PYTHON_ROOT ?= /usr ;
if ! $(NT)
{
PYTHON_ROOT ?= $(CYGWIN_PYTHON_ROOT) ;
}
if $(CYGWIN_PYTHON_ROOT) = /usr
{
CYGWIN_PYTHON_DLL_PATH ?= /bin ;
}
else
{
CYGWIN_PYTHON_DLL_PATH ?= $(CYGWIN_PYTHON_ROOT)/bin ;
}
CYGWIN_PYTHON_VERSION ?= $(PYTHON_VERSION) ;
CYGWIN_PYTHON_LIB_PATH ?= $(CYGWIN_PYTHON_ROOT)/lib/python$(CYGWIN_PYTHON_VERSION)/config ;
CYGWIN_PYTHON_DEBUG_VERSION ?= $(CYGWIN_PYTHON_VERSION) ;
CYGWIN_PYTHON_DEBUG_ROOT ?= $(PYTHON_ROOT) ;
CYGWIN_PYTHON_DEBUG_DLL_PATH ?= $(CYGWIN_PYTHON_DEBUG_ROOT)/bin ;
CYGWIN_PYTHON_DEBUG_LIB_PATH ?= $(CYGWIN_PYTHON_DEBUG_ROOT)/lib/python$(CYGWIN_PYTHON_DEBUG_VERSION)/config ;
}
else if $(UNIX)
{
# PYTHON_EMBEDDED_LIBRARY: Libraries to include when
# embedding Python in C++ code. We need the Python library,
# libdl for dynamic loading and possibly libutil on BSD-like
# systems (including Linux). A dynamic libpython should
# automatically pick up the libutil dependency, but we cannot
# tell here if we are linking with a static or dynamic
# libpython, so we include libutil for all UNIX systems where
# it is available.
if $(OS) = MACOSX
{
PYTHON_EMBEDDED_LIBRARY = ;
}
else if $(OS) = SOLARIS
{
PYTHON_EMBEDDED_LIBRARY = python$(PYTHON_VERSION) dl ;
}
else if $(OS) = OSF
{
PYTHON_EMBEDDED_LIBRARY = python$(PYTHON_VERSION) ;
}
else
{
PYTHON_EMBEDDED_LIBRARY = python$(PYTHON_VERSION) dl util ;
}
}
if $(NT)
{
PYTHON_ROOT ?= c:/Python$(PYTHON_VERSION_NODOT) ;
# Reconstitute any paths split due to embedded spaces.
PYTHON_ROOT = $(PYTHON_ROOT:J=" ") ;
PYTHON_LIB_PATH ?= $(PYTHON_ROOT)/libs [ GLOB $(PYTHON_ROOT) : PCbuild ] ;
PYTHON_INCLUDES ?= $(PYTHON_ROOT)/include ;
PYTHON_DLL ?= [ GLOB $(PYTHON_ROOT) $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT).dll ] ;
PYTHON_DEBUG_DLL ?= [ GLOB $(PYTHON_ROOT) $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT)_d.dll ] ;
PYTHON_IMPORT_LIB ?= [ GLOB $(PYTHON_LIB_PATH) : libpython$(PYTHON_VERSION_NODOT).* ] ;
PYTHON_DEBUG_IMPORT_LIB ?= [ GLOB $(PYTHON_LIB_PATH) : libpython$(PYTHON_VERSION_NODOT).* ] ;
}
else if $(UNIX) && $(OS) = MACOSX
{
if ! $(PYTHON_ROOT)
{
if [ GLOB /System/Library/Frameworks : Python.framework ]
{
PYTHON_ROOT ?= /System/Library/Frameworks/Python.framework/Versions/$(PYTHON_VERSION) ;
}
else
{
PYTHON_ROOT ?= /Library/Frameworks/Python.framework/Versions/$(PYTHON_VERSION) ;
}
}
PYTHON_ROOT = $(PYTHON_ROOT:J=" ") ;
PYTHON_INCLUDES ?= $(PYTHON_ROOT)/include/python$(PYTHON_VERSION) ;
PYTHON_FRAMEWORK ?= $(PYTHON_ROOT) ;
while $(PYTHON_FRAMEWORK:D=) && $(PYTHON_FRAMEWORK:D=) != Python.framework
{
PYTHON_FRAMEWORK = $(PYTHON_FRAMEWORK:D) ;
}
PYTHON_FRAMEWORK = $(PYTHON_FRAMEWORK:D)/Python ;
PYTHON_PROPERTIES ?=
<sysinclude>$(PYTHON_INCLUDES)
;
}
else if $(UNIX)
{
PYTHON_ROOT ?= /usr ;
PYTHON_ROOT = $(PYTHON_ROOT:J=" ") ;
PYTHON_INCLUDES ?= $(PYTHON_ROOT)/include/python$(PYTHON_VERSION) ;
PYTHON_LIB_PATH ?= $(PYTHON_ROOT)/lib/python$(PYTHON_VERSION)/config ;
PYTHON_PROPERTIES ?=
<sysinclude>$(PYTHON_INCLUDES)
<library-path>$(PYTHON_LIB_PATH)
<default>python-intel-use-gcc-stdlib
python-static-multithread
;
if $(OS) = OSF
{
local not-gcc-compilers = [ difference $(TOOLS) : $(gcc-compilers) ] ;
PYTHON_PROPERTIES +=
<$(not-gcc-compilers)><*><linkflags>"-expect_unresolved 'Py*' -expect_unresolved '_Py*'"
<$(gcc-compilers)><*><linkflags>"-Xlinker -expect_unresolved -Xlinker 'Py*' -Xlinker -expect_unresolved -Xlinker '_Py*'" ;
}
else if $(OS) = AIX
{
PYTHON_PROPERTIES
+= <*><*><linkflags>"-Wl,-bI:$(PYTHON_LIB_PATH)/python.exp"
<*><*><find-library>pthreads ;
}
}
#
# Locate the python executable(s)
#
CYGWIN_ROOT ?= c:/cygwin ;
{
for local cyg in "" CYGWIN_
{
for local d in "" _D
{
local d_D = _DEBUG ;
local debug = $(d$(d)) ; # "" or _DEBUG
# select base name of variables
local var-base = $(cyg)PYTHON$(debug) ;
# Base defaults for the debug build on the non-debug
$(var-base)_VERSION ?= $($(cyg)PYTHON_VERSION) ;
$(var-base)_ROOT ?= $($(cyg)PYTHON_ROOT) ;
# Version number element of executable name
local exe-version = $($(var-base)_VERSION) ;
if $(NT) && ! $(cyg) { exe-version = $(d:L) ; }
# assign default target name
local executable = $(cyg)PYTHON$(d) ;
$(executable) ?= <$(cyg)EXE$(d)@>python$(exe-version)$(SUFEXE) ;
# choose the appropriate root directory/ies to search for the target
local r = $($(var-base)_ROOT) ;
if $(NT)
{
switch $(r)
{
case [/\\]* : # in case of unix-style path
r = $(CYGWIN_ROOT)$(r) $(r) ; # re-root for windows
}
}
# set up search path
SEARCH on $($(executable))
= $(r)/bin # Standard locations
$(r) # Standard locations
$(r)/PCBuild # In case building from a windows development Python
$(RUN_PATH) # Just look in the path
;
}
}
}
# Normally on Linux, Python is built with GCC. A "poor QOI choice" in
# the implementation of the intel tools prevents the use of
# intel-linked shared libs by a GCC-built executable unless they have
# been told to use the GCC runtime. This rule adds the requisite
# flags to the compile and link lines.
rule python-intel-use-gcc-stdlib ( toolset variant : non-defaults * )
{
if ( ! $(PYTHON_WINDOWS) )
&& ( ! <define>BOOST_PYTHON_STATIC_LIB in $(non-defaults) )
&& [ MATCH (intel) : $(toolset) ]
{
return <stdlib>gcc ;
}
else
{
return ;
}
}
# Force statically-linked embedding applications to be multithreaded
# on UNIX.
rule python-static-multithread ( toolset variant : properties * )
{
if ! $(PYTHON_WINDOWS)
{
local x = <define>BOOST_PYTHON_STATIC_LIB <threading>single ;
if $(x) in $(properties)
{
properties = [ difference $(properties) : <threading>single ] <threading>multi ;
}
}
return $(properties) ;
}
# Borland compilers are not supported
rule boost-python-disable-borland ( toolset variant : properties * )
{
if [ MATCH .*(bcc|borland).* : $(toolset) ]
{
properties += <build>no ;
}
return $(properties) ;
}
# select-python-library
#
# Ungristed elements of a requirements list are treated as the rule
# names to be called to transform the property set. This is used when
# the requirements are too complicated to express otherwise. This
# rule selects the right python library when building on Windows.
rule select-python-library ( toolset variant : properties * )
{
if $(PYTHON_WINDOWS)
{
if $(toolset) in $(gcc-compilers)
{
if <define>BOOST_DEBUG_PYTHON in $(properties)
{
properties += <library-path>$(CYGWIN_PYTHON_DEBUG_LIB_PATH) <find-library>python$(CYGWIN_PYTHON_DEBUG_VERSION).dll ;
}
else
{
properties += <library-path>$(CYGWIN_PYTHON_LIB_PATH) <find-library>python$(CYGWIN_PYTHON_VERSION).dll ;
}
}
else if [ MATCH .*(mingw).* : $(toolset) ]
{
local lib = $(PYTHON_IMPORT_LIB) ;
if <define>BOOST_DEBUG_PYTHON in $(properties)
{
lib = $(PYTHON_DEBUG_IMPORT_LIB) ;
}
lib ?= $(PYTHON_DLL) ;
if <define>BOOST_DEBUG_PYTHON in $(properties)
{
lib ?= $(PYTHON_DEBUG_DLL) ;
}
properties += <library-file>$(lib) ;
}
else
{
properties += <library-path>$(PYTHON_LIB_PATH) ;
if $(toolset) != msvc # msvc compilers auto-find the python library
{
properties += <library-path>$(PYTHON_LIB_PATH) ;
local lib = python$(PYTHON_VERSION_NODOT) ;
if <define>BOOST_DEBUG_PYTHON in $(properties)
{
lib = python$(PYTHON_VERSION_NODOT)_d ;
}
properties += <find-library>$(lib) ;
}
}
}
if $(OS) = MACOSX && [ MATCH .*(darwin).* : $(toolset) ]
{
if <target-type>PYD in $(properties)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -