# the cross platfrom stub ext_stub = Extension("_tosdb", sources=["_tosdb.cpp"], include_dirs=["../include"], optional=True) ext_win = Extension(**ext_stub.__dict__) # add/override for Win ext_win.library_dirs = ["../bin/Release/" + _SYS_ARCHD] ext_win.libraries = [ "_tos-databridge-shared-" + _SYS_ARCH, "_tos-databridge-static-" + _SYS_ARCH ] ext_win.define_macros = [("THIS_IMPORTS_IMPLEMENTATION", None), ("THIS_DOESNT_IMPORT_INTERFACE", None)] ext_win.extra_compile_args = ["/EHsc"] ext_win.extra_link_args = ["/LTCG"] try: # capture setup errors but allow setup to complete (optional=True) sio = StringIO() se = sys.stderr sys.stderr = sio setup(ext_modules=[ext_win if _SYS_IS_WIN else ext_stub], **setup_dict) sys.stderr = se if sio.getvalue(): print('\n', "+ Operation 'completed' with errors:\n") print(sio.getvalue()) print("+ Checking on the status of the build...") t = None try:
from distutils.core import setup from distutils.core import Extension import os import subprocess import sys module = Extension("simplepinyin", ["simplepinyin.cpp"]) module.language = 'c++' if os.system("pkg-config --exists libpinyin") != 0: print("Please install libpinyin.", file=sys.stderr) sys.exit(1) libpinyin_args = subprocess.check_output(["pkg-config", "--cflags", "--libs", "libpinyin"], universal_newlines=True).strip().split(" ") libpinyin_data = subprocess.check_output(["pkg-config", "--variable=pkgdatadir", "libpinyin"], universal_newlines=True).strip()+"/data" #print(libpinyin_data) module.include_dirs = [arg.lstrip("-I") for arg in libpinyin_args if arg.startswith("-I")] module.library_dirs = [arg.lstrip("-L") for arg in libpinyin_args if arg.startswith("-L")] module.libraries = [arg.lstrip("-l") for arg in libpinyin_args if arg.startswith("-l")] module.define_macros = [("LIBPINYIN_DATA", "\""+libpinyin_data+"\"")] setup(name="simplepinyin", version="1.0", ext_modules=[module])
"packages": ['tosdb','tosdb/cli_scripts'] } # the cross platfrom stub ext_stub = Extension( "_tosdb", sources=[ "_tosdb.cpp" ], include_dirs=[ "../include" ], optional=True ) ext_win = Extension( **ext_stub.__dict__ ) # add/override for Win ext_win.library_dirs = [ "../bin/Release/"+ _SYS_ARCHD ] ext_win.libraries = [ "_tos-databridge-shared-"+ _SYS_ARCH, "_tos-databridge-static-"+ _SYS_ARCH ] ext_win.define_macros = [ ("THIS_IMPORTS_IMPLEMENTATION",None), ("THIS_DOESNT_IMPORT_INTERFACE",None) ] ext_win.extra_compile_args = ["/EHsc"] ext_win.extra_link_args = ["/LTCG"] try: # capture setup errors but allow setup to complete (optional=True) sio = StringIO() se = sys.stderr sys.stderr = sio setup( ext_modules=[ ext_win if _SYS_IS_WIN else ext_stub], **setup_dict ) sys.stderr = se if sio.getvalue(): print( '\n', "+ Operation 'completed' with errors:\n") print( sio.getvalue() ) print( "+ Checking on the status of the build...") t = None try: