a tiny package for fast python c++ binding build.
Project description
ccimport
a tiny package for fast python c++ binding build.
support python 3.5, 3.7-3.9.
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_EXPORTbefore your function declaration name. For class, write a static factory member that return a unique_ptr, then addCODEAI_EXPORT_INITbefore it. -
use
ccimport.autoimportto build extension.
Multiple File Extension
-
Add
CODEAI_EXPORTand/orCODEAI_EXPORT_INITin header files. -
Implement functions and classes in source files.
-
use
ccimport.autoimportto build extension. you need to add all header files withCODEAI_EXPORTtosourcesparameter.
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_kw="CODEAI_EXPORT", # use the macro to mark a exported function.
export_init_kw="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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ccimport-0.1.19.tar.gz.
File metadata
- Download URL: ccimport-0.1.19.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c3843bafd56d86ee2a1573b459563d5d78be37ecebd57211e11ae2b3b4256a5
|
|
| MD5 |
51297482e5b46e8b852a6c854052885a
|
|
| BLAKE2b-256 |
e64db8ded60926d1eb5b758e45df7f4f33a2bfe8f0134865e1ee8e28cf405e04
|
File details
Details for the file ccimport-0.1.19-py3-none-any.whl.
File metadata
- Download URL: ccimport-0.1.19-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b99cc456ad0998b1c5c372ad964e85efc2c8e9641f075202e1dc2d52eebe73ef
|
|
| MD5 |
e90253d5b9182172ddc48bfe516a65ed
|
|
| BLAKE2b-256 |
12a5e8b533cb31e87c000c7be7d6bf38335dc92792137310ae0accfe0a812b02
|