from distutils.core import setup, Extension import numpy module = Extension("multivec", ["wrapper.cpp", "../multivec/monolingual.cpp", "../multivec/bilingual.cpp", "../multivec/distance.cpp"], undef_macros=['NDEBUG']) module.extra_compile_args = ['--std=c++0x', '-w', '-I../multivec', '-O3'] module.libraries = ['m'] setup(name="multivec", version="1.0", ext_modules=[module], include_dirs=[numpy.get_include()])
"author_email": "*****@*****.**", "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())
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])
from distutils.core import setup, Extension import subprocess module=Extension('pywlc', ['wlc_python.c']) module.libraries = ['wlc'] module.extra_compile_args=[subprocess.check_output(["wlc-config", "--cflags"])] module.extra_link_args=[subprocess.check_output(["wlc-config", "--libs"])] setup(name='pywlc', version='0.0', ext_modules=[module])
def compile_c_extension( generated_source_path: str, build_dir: Optional[str] = None, verbose: bool = False, keep_asserts: bool = True, disable_optimization: bool = False, library_dir: Optional[str] = None, ) -> str: """Compile the generated source for a parser generator into an extension module. The extension module will be generated in the same directory as the provided path for the generated source, with the same basename (in addition to extension module metadata). For example, for the source mydir/parser.c the generated extension in a darwin system with python 3.8 will be mydir/parser.cpython-38-darwin.so. If *build_dir* is provided, that path will be used as the temporary build directory of distutils (this is useful in case you want to use a temporary directory). If *library_dir* is provided, that path will be used as the directory for a static library of the common parser sources (this is useful in case you are creating multiple extensions). """ import distutils.log from distutils.core import Distribution, Extension from distutils.tests.support import fixup_build_ext # type: ignore from distutils.ccompiler import new_compiler from distutils.dep_util import newer_group from distutils.sysconfig import customize_compiler if verbose: distutils.log.set_threshold(distutils.log.DEBUG) source_file_path = pathlib.Path(generated_source_path) extension_name = source_file_path.stem extra_compile_args = get_extra_flags("CFLAGS", "PY_CFLAGS_NODIST") extra_compile_args.append("-DPy_BUILD_CORE_MODULE") # Define _Py_TEST_PEGEN to not call PyAST_Validate() in Parser/pegen.c extra_compile_args.append("-D_Py_TEST_PEGEN") extra_link_args = get_extra_flags("LDFLAGS", "PY_LDFLAGS_NODIST") if keep_asserts: extra_compile_args.append("-UNDEBUG") if disable_optimization: if sys.platform == 'win32': extra_compile_args.append("/Od") extra_link_args.append("/LTCG:OFF") else: extra_compile_args.append("-O0") if sysconfig.get_config_var("GNULD") == "yes": extra_link_args.append("-fno-lto") common_sources = [ str(MOD_DIR.parent.parent.parent / "Python" / "Python-ast.c"), str(MOD_DIR.parent.parent.parent / "Python" / "asdl.c"), str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer.c"), str(MOD_DIR.parent.parent.parent / "Parser" / "pegen.c"), str(MOD_DIR.parent.parent.parent / "Parser" / "pegen_errors.c"), str(MOD_DIR.parent.parent.parent / "Parser" / "action_helpers.c"), str(MOD_DIR.parent.parent.parent / "Parser" / "string_parser.c"), str(MOD_DIR.parent / "peg_extension" / "peg_extension.c"), ] include_dirs = [ str(MOD_DIR.parent.parent.parent / "Include" / "internal"), str(MOD_DIR.parent.parent.parent / "Parser"), ] extension = Extension( extension_name, sources=[generated_source_path], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) dist = Distribution({"name": extension_name, "ext_modules": [extension]}) cmd = dist.get_command_obj("build_ext") fixup_build_ext(cmd) cmd.build_lib = str(source_file_path.parent) cmd.include_dirs = include_dirs if build_dir: cmd.build_temp = build_dir cmd.ensure_finalized() compiler = new_compiler() customize_compiler(compiler) compiler.set_include_dirs(cmd.include_dirs) compiler.set_library_dirs(cmd.library_dirs) # build static lib if library_dir: library_filename = compiler.library_filename(extension_name, output_dir=library_dir) if newer_group(common_sources, library_filename, 'newer'): if sys.platform == 'win32': pdb = compiler.static_lib_format % (extension_name, '.pdb') compile_opts = [f"/Fd{library_dir}\\{pdb}"] compile_opts.extend(extra_compile_args) else: compile_opts = extra_compile_args objects = compiler.compile(common_sources, output_dir=library_dir, debug=cmd.debug, extra_postargs=compile_opts) compiler.create_static_lib(objects, extension_name, output_dir=library_dir, debug=cmd.debug) if sys.platform == 'win32': compiler.add_library_dir(library_dir) extension.libraries = [extension_name] elif sys.platform == 'darwin': compiler.set_link_objects([ '-Wl,-force_load', library_filename, ]) else: compiler.set_link_objects([ '-Wl,--whole-archive', library_filename, '-Wl,--no-whole-archive', ]) else: extension.sources[0:0] = common_sources # Compile the source code to object files. ext_path = cmd.get_ext_fullpath(extension_name) if newer_group(extension.sources, ext_path, 'newer'): objects = compiler.compile(extension.sources, output_dir=cmd.build_temp, debug=cmd.debug, extra_postargs=extra_compile_args) else: objects = compiler.object_filenames(extension.sources, output_dir=cmd.build_temp) # Now link the object files together into a "shared object" compiler.link_shared_object( objects, ext_path, libraries=cmd.get_libraries(extension), extra_postargs=extra_link_args, export_symbols=cmd.get_export_symbols(extension), debug=cmd.debug, build_temp=cmd.build_temp) return pathlib.Path(ext_path)
from distutils.core import setup, Extension from Cython.Build import cythonize import numpy sources = ["multivec.pyx", "../multivec/monolingual.cpp", "../multivec/bilingual.cpp", "../multivec/distance.cpp"] module = Extension("multivec", sources, undef_macros=['NDEBUG'], language="c++") module.extra_compile_args = ['--std=c++11', '-w', '-I../multivec', '-O3'] module.libraries = ['m'] setup(name="multivec", version="1.0", ext_modules=cythonize([module]), include_dirs=[numpy.get_include()])
#!/usr/bin/env python # Author: Thomas Liu <*****@*****.**> import os from distutils.core import setup, Extension LIBS=["apol", "qpol"] try: inc=os.getenv("INCLUDES").split(" ") INCLUDES=map(lambda x: x[2:], inc) LIBDIRS=map(lambda x: "/".join(x.split("/")[:-1]), os.getenv("LIBS").split()) except: INCLUDES="" LIBDIRS="" extension_sesearch = Extension("setools._sesearch", [ "sesearch.c"]) extension_sesearch.include_dirs=INCLUDES extension_sesearch.libraries=LIBS extension_sesearch.library_dirs=LIBDIRS extension_seinfo = Extension("setools._seinfo", [ "seinfo.c"]) extension_seinfo.include_dirs=INCLUDES extension_seinfo.libraries=LIBS extension_seinfo.library_dirs=LIBDIRS setup(name = "setools", version="1.0", description="Python setools bindings", author="Thomas Liu", author_email="*****@*****.**", ext_modules=[extension_sesearch, extension_seinfo], packages=["setools"])
"author":"Jonathon Ogden", "author_email":"*****@*****.**", "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...")