Just a collection of Boost Python examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
BoostPython/setup.py

107 lines
2.8 KiB

#!/usr/bin/env python3
from os import environ
from os.path import join
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
def pEpLog(*msg):
import inspect
msgstr = ''
separator = ' '
for m in msg:
msgstr += str(m)
msgstr += separator
func = inspect.currentframe().f_back.f_code
print(func.co_filename + " : " + func.co_name + " : " + msgstr)
class CustomBuildExt(build_ext):
user_options = build_ext.user_options + [
('prefix=', None, 'additional dir for libs/includes')
]
def initialize_options(self):
build_ext.initialize_options(self)
self.prefix = getattr(self, "prefix=", None)
def get_build_info_linux(self):
home = environ.get('HOME')
sys_includes = [
'/usr/local/include',
]
sys_libdirs = []
libs = [
'boost_python37',
'boost_locale'
]
return (home, sys_includes, sys_libdirs, libs)
def finalize_options(self):
build_ext.finalize_options(self)
pEpLog("debug: ", self.debug)
pEpLog("prefix: ", self.prefix)
build_info = self.get_build_info_linux()
(home, sys_includes, sys_libdirs, libs) = build_info
# Build the Includes -I and Library paths -L
# Start empty
includes = []
libdirs = []
# Append prefix-dir
if self.prefix:
pEpLog("using prefix=",self.prefix)
prefix_include=[ join(self.prefix, 'include') ]
prefix_libdirs=[ join(self.prefix, 'lib') ]
includes += prefix_include
libdirs += prefix_libdirs
# Append default system dirs
includes += sys_includes
libdirs += sys_libdirs
# Compile flags
compile_flags = ['-std=c++14']
if self.debug:
pEpLog("debug build mode")
compile_flags += ['-O0', '-g', '-UNDEBUG']
# Apply the build information
global hello_world
hello_world.include_dirs = includes
hello_world.library_dirs = libdirs
hello_world.libraries = libs
hello_world.extra_compile_args = compile_flags
pEpLog("Include Dirs:", hello_world.include_dirs)
pEpLog("Libs Dirs:", hello_world.library_dirs)
pEpLog("Libraries:", hello_world.libraries)
pEpLog("Compile flags:", hello_world.extra_compile_args)
def run(self):
build_ext.run(self)
hello_world = Extension(
name = '_hello_world',
sources = ['src/hello_world/_hello_world/_hello_world.cc']
)
# "MAIN" Function
setup(
name='hello_world',
version='0.1',
package_dir={'':'src'},
packages=['hello_world'],
ext_modules=[hello_world],
cmdclass={
'build_ext': CustomBuildExt,
}
)