PyCLIF callback_test.py: Add
testPassNoneAsCallbackThis CL was used in a PyCLIF-pybind11 TGP (cl/667456010, 2024-08-26):
http://tap/OCL:667456010:BASE:667610796:1724689781533:d2626456:
571 Failing Targets 147 Broken TargetsFor this to work, a pybind11clif fix is needed (merged already):
See also: https://b.corp.google.com/issues/287289622#comment75
PiperOrigin-RevId: 668995414
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
C++ Language Interface Foundation (CLIF)
THIS REPO IS NO LONGER UPDATED — DO NOT USE
STALE INFORMATION FOLLOWS
PyCLIF defines a C++ API to be wrapped via a concise What You See Is What You Get interface file (example)), with a syntax derived from pytypedecl.
About the name of this repo: CLIF was started as a common foundation for creating C++ wrapper generators for various languages. However, currently Python is the only target language, and there is no development activity for other target languages.
Overview
PyCLIF consists of four parts:
Parser
The parser converts a language-friendly C++ API description to the language-agnostic internal format and passes it to the Matcher.
Matcher
The matcher parses selected C++ headers with Clang (LLVM’s C++ compiler) and collects type information. That info is passed to the Generator.
Generator
The generator emits C++ source code for the wrapper.
The generated wrapper needs to be built according with language extension rules. Usually that wrapper will call into the Runtime.
Runtime
The runtime C++ library holds type conversion routines that are specific to each target language but are the same for every generated wrapper.
Python CLIF
See complete implementation of a Python wrapper generator in the
/python/subdirectory. Both Python 2 and 3 are supported.Installation
Prerequisites
We use CMake, so make sure CMake version 3.5 or later is available. (For example, Debian 8 only has version 3.0, so in that case you’ll need to install an up-to-date CMake.)
We use Google protobuf for inter-process communication between the CLIF frontend and backend. Version 3.8.0 or later is required. Please install protobuf for both C++ and Python from source, as we will need some protobuf source code later on.
You must have virtualenv installed.
You must have pyparsing installed, so we can build protobuf. Use
pip install 'pyparsing==2.2.2'to fetch the correct version.Make sure
pkg-config --libs pythonworks (e.g. installpython-devandpkg-config).We use Clang (LLVM’s C++ compiler) to parse C++ headers, so make sure Clang and LLVM version 11 is available. On Ubuntu and Debian, you can install the prebuilt version from https://apt.llvm.org.
You must have abseil-cpp installed.
We use googletest for unit testing C++ libraries.
For references, there is a Dockerfile running an Ubuntu image with all the prerequisites already installed. See the instructions at the top of the file.
Building
To build and install CLIF to a virtualenv, run:
The following outlines the steps in
INSTALL.shfor clarification.Build and install the CLIF backend. If you use Ninja instead of
makeyour build will go significantly faster. It is used by Chromium, LLVM et al. Look atINSTALL.shfor the directory setup and proper …flags… to supply thecmakecommand here:Replace the cmake and make commands with these to use Ninja:
If you have more than one Python version installed (eg. python3.8 and python3.9) cmake may have problems finding python libraries for the Python you specified as INSTALL.sh argument and uses the default Python instead. To help cmake use the correct Python add the following options to the cmake command (substitute the correct path for your system):
Get back to your CLIF python checkout and install it using pip.
That version is guaranteed to work. Older versions likely do not work (they lack some APIs); later versions might work, at your own risk.
INSTALL.sh will build and install clif-matcher to CMake install directory and CLIF for Python to the given Python (virtual) environment.
To run Python CLIF use
pyclif.Using your newly built pyclif
First, try some examples:
Next, read the Python CLIF User Manual.
For more details please refer to:
Disclaimer
This is not an official Google product.