High-performance Python bindings for Chromium Embedded Framework (CEF)
Video testing: https://youtu.be/yWIah-r6sbw?si=O_uNuDDE8uSf6-Nk
Thanks to pybind11 and CEF for existing in this world. This project is inspired from cefpython
Note
Complete examples of using with Kivy, Tkinter and PyQt6 are under examples.
Tip
NfsBrowser is a modern web browser built with Python, integrating Kivy, CarbonKivy, and the Chromium Embedded Framework (CEF) via pybindcef.
Note
Only for versions > 0.1.0
Build and Install using automated build scripts.
Clone the repo locally:
git clone https://github.com/Novfensec/pybindcef -b main --single-branch --depth 1
cd pybindcef-
Linux:
chmod +x ./build.sh ./build.sh pip install . -
Windows (Powershell):
Install the necessary C++ build tools and CMake using Windows Package Manager (
winget):This has to be done only once.
winget install -e --id Microsoft.VisualStudio.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended" --source winget winget install -e --id Kitware.CMake --source winget
- Run the build script in powershell:
powershell -ExecutionPolicy ByPass -c .\build.ps1
- Then simply install via pip:
pip install .
Better watch a video:
- for
v0.1.0: https://youtu.be/3ZYGRoq0yno?si=SHUavAi3QQssk8rD - for
latest: Not yet out there
Latest build instructions
-
Linux
Install necessary build tools:
sudo apt update sudo apt install -y build-essential cmake ninja-buildDownload cef minimal build for your system architecture via https://cef-builds.spotifycdn.com/index.html
mkdir -p ~/Downloads/cef_binary wget https://cef-builds.spotifycdn.com/cef_binary_151.3.24%2Bg2384915%2Bchromium-151.0.7922.174_linux64.tar.bz2 -O ~/Downloads/cef_binary.tar.bz2 tar -xjf ~/Downloads/cef_binary.tar.bz2 -C ~/Downloads/cef_binary --strip-components=1
Now build the
libcef_dll_wrappermkdir ~/Downloads/cef_binary/build cd ~/Downloads/cef_binary/build cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON make -j$(nproc) libcef_dll_wrapper
Confirm the build
ls ~/Downloads/cef_binary/build/libcef_dll_wrapperA file named
libcef_dll_wrapper.awill be listed. -
Windows
Install the necessary C++ build tools and CMake using Windows Package Manager (
winget):# Install Visual C++ Build Tools winget install Microsoft.VisualStudio.BuildTools # Install CMake winget install Kitware.CMake
Download cef minimal/standard build for your system architecture via https://cef-builds.spotifycdn.com/index.html
Powershell commands below
mkdir $env:USERPROFILE\Downloads\cef_binary wget "https://cef-builds.spotifycdn.com/cef_binary_151.3.24%2Bg2384915%2Bchromium-151.0.7922.174_windows64.tar.bz2" ` -O $env:USERPROFILE\Downloads\cef_binary.tar.bz2 tar -xjf $env:USERPROFILE\Downloads\cef_binary.tar.bz2 -C $env:USERPROFILE\Downloads\cef_binary --strip-components=1
Now build the
libcef_dll_wrappermkdir $env:USERPROFILE\Downloads\cef_binary\build cd $env:USERPROFILE\Downloads\cef_binary\build # enable msvc build environment for you system x64 x86_64 x86 amd64 # You can start the developer command prompt and type `where vcvarsall` to see the exact path # then simply paste that path to run e.g. C:\Program Files (x86)\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvarsall.bat vcvarsall.bat amd64 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON cmake --build . --config Release --target libcef_dll_wrapper --parallel
Confirm the build
Get-ChildItem $env:USERPROFILE\Downloads\cef_binary\build\libcef_dll_wrapper\ReleaseA file named
libcef_dll_wrapper.libwill be listed.
PyPI: https://pypi.org/project/pybindcef/
-
Linux
Install pybind11.
pip install "pybind11[global]"Clone this repository.
git clone https://github.com/Novfensec/pybindcef -b main --single-branch --depth 1
Now install via pip:
pip install . -
Windows
Install pybind11.
pip install "pybind11[global]"Clone this repository.
git clone https://github.com/Novfensec/pybindcef -b main --single-branch --depth 1
Now install via pip:
pip install .
After building and installing via pip install . (or the automated scripts), you can run the examples directly:
python examples/kivy/main.pyThe python module resolves the bundled CEF dependencies internally.