a tiny package for fast python c++ binding build.
Project description
ccimport
a tiny package for fast python c++ binding build.
Usage
Limitations in Code
- Function/class with template parameter aren't supported. If you really need to use template, you need to provide all parameters with a default value. The generated code will use
func<>
to bind your code.
Single File Extension
-
Add
CODEAI_EXPORT
before your function declaration name. For class, write a static factory member that return a unique_ptr, then addCODEAI_EXPORT_INIT
before it. -
use
ccimport.autoimport
to build extension.
Multiple File Extension
-
Add
CODEAI_EXPORT
and/orCODEAI_EXPORT_INIT
in header files. -
Implement functions and classes in source files.
-
use
ccimport.autoimport
to build extension. you need to add all header files withCODEAI_EXPORT
tosources
parameter.
Library without pybind
- Use ccimport.ccimport instead.
API
- ccimport.autoimport
def autoimport(sources: List[Union[str, Path]], # list of source path, may include headers with 'CODEAI_EXPORT'
out_path: Union[str, Path], # output path. the name of output file must be a name
# without platform library prefix and suffix such as `lib-`, '.so'.
includes: Optional[List[Union[str, Path]]] = None, # include paths
libpaths: Optional[List[Union[str, Path]]] = None, # library paths
libraries: Optional[List[str]] = None, # libraries. the name of library must be a name
# without platform library prefix and suffix such as `lib-`, '.so'.
export_keyword="CODEAI_EXPORT", # use the macro to mark a exported function.
export_init_keyword="CODEAI_EXPORT_INIT", # use the macro to mark a static class factory member.
compile_options: Optional[List[str]] = None, # compile options.
link_options: Optional[List[str]] = None, # link options.
std="c++14", # c++ standard.
additional_cflags: Optional[Dict[str, List[str]]] = None): # compiler to compile options
pass
- ccimport.ccimport
def ccimport(source_paths: List[Union[str, Path]],
out_path: Union[str, Path],
includes: Optional[List[Union[str, Path]]] = None,
libpaths: Optional[List[Union[str, Path]]] = None,
libraries: Optional[List[str]] = None,
compile_options: Optional[List[str]] = None,
link_options: Optional[List[str]] = None,
source_paths_for_hash: Optional[List[Union[str, Path]]] = None, # if provided, the content of source files will be used
# for change detection.
std="c++14",
build_ctype=False, # if True, a standard shared library will be built. otherwise a pybind library will be built
disable_hash=True, # if True, source-content based change detection will be used.
load_library=True, # if True, the library will be loaded by python or ctypes.CDLL
additional_cflags: Optional[Dict[str, List[str]]] = None):
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ccimport-0.1.2.tar.gz
(21.1 kB
view details)
Built Distribution
ccimport-0.1.2-py3-none-any.whl
(20.5 kB
view details)
File details
Details for the file ccimport-0.1.2.tar.gz
.
File metadata
- Download URL: ccimport-0.1.2.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aed4f11135ae3ec0c45830885a9cf2e8689b03c10ee2c09907d0cf380c7a3c2 |
|
MD5 | ba084fc59e41903dbe275e2066d99037 |
|
BLAKE2b-256 | 4de8dc9a14105e23b2b815de7b38ee1c0bcae46a20765fa1f5bf35cf52220b43 |
File details
Details for the file ccimport-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: ccimport-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93fa5a38a1062b6eb62f3d63293c5e15e1882eaf2e4608cfa60e8d53caae4635 |
|
MD5 | 32935b1ca1795f587151c8160f1d3221 |
|
BLAKE2b-256 | 2c1745b0e6b4cb7d90ecad1e3d61ef9091fd9c40d6b92317416923684fb868bc |