Skip to content

Novfensec/pybindcef

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pybindcef

High-performance Python bindings for Chromium Embedded Framework (CEF)

Experimental and it works damn good.

Video testing: https://youtu.be/yWIah-r6sbw?si=O_uNuDDE8uSf6-Nk

Complete examples of using with Kivy, Tkinter and PyQt6 are under tests.

Thanks to pybind11 and CEF for existing in this world.

Financial Support

If and only if you want to support me anyhow:

Donate via

Donate via PayPal

GitHub Sponsors

Build Instructions

Better watch a video (and there is not a video yet, lol)!!

Building libcef_dll_wrapper

  • Linux

    Download 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_146.0.9%2Bg3ca6a87%2Bchromium-146.0.7680.165_linux64_minimal.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_wrapper

    mkdir ~/Downloads/cef_binary/build
    cd ~/Downloads/cef_binary/build
    
    cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON
    make -j$(nproc)

    Confirm the build

    ls ~/Downloads/cef_binary/build/libcef_dll_wrapper/
    

    A file named libcef_dll_wrapper.a will be listed.

  • Windows

    Download cef minimal 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_146.0.9%2Bg3ca6a87%2Bchromium-146.0.7680.165_windows64_minimal.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_wrapper

    mkdir $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
    vcvarsall.bat amd64
    
    cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON
    cmake --build . --config Release --parallel

    Confirm the build

    Get-ChildItem $env:USERPROFILE\Downloads\cef_binary\build\libcef_dll_wrapper\Release
    

    A file named libcef_dll_wrapper.lib will be listed.

Building pybindcef extension

PyPI: https://pypi.org/project/pybindcef/

  • Linux

    Install bare bones extension from pypi:

    pip install pybindcef

    OR BUILD FROM SOURCE:

    Install pybind11.

    pip install "pybind11[global]"

    Clone this repository.

    git clone https://github.com/Novfensec/pybindcef -b main --single-branch --depth 1

    Now build the extension with -DPython_EXECUTABLE="pythonexecutablewithversion"

    mkdir pybindcef/build
    cd pybindcef/build
    
    cmake .. -DPython_EXECUTABLE=/usr/bin/python
    make
  • Windows

    Install pybind11.

    pip install "pybind11[global]"

    Clone this repository.

    git clone https://github.com/Novfensec/pybindcef -b main --single-branch --depth 1

    Now build the extension.

    mkdir pybindcef/build
    cd pybindcef/build
    
    cmake .. -DCMAKE_BUILD_TYPE=Release
    cmake --build . --config Release

Building cef_worker

  • Linux

    mkdir pybindcef/cef_worker/build
    cd pybindcef/cef_worker/build
    
    cmake ..
    make
  • Window

    mkdir pybindcef/cef_worker/build
    cd pybindcef/cef_worker/build
    
    cmake .. -DCMAKE_BUILD_TYPE=Release
    cmake --build . --config Release

Extracting resources

  • Linux

    Copy all files under cef_binary/Resources to cef_binary/Release

    cp -r ~/Downloads/cef_binary/Resources/* ~/Downloads/cef_binary/Release/
  • Windows

    Copy all files under cef_binary/Resources and cef_binary/Release right next to the extension from wherever you are accessing it. All you need to do is make libcef.dll available in LD_LIBRARY_PATH and place the files under cef_binary/Resources next to libcef.dll that's it.

Tests

Linux

  1. Kivy

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/kivy/.
    • Run main.py with the python executable version suitable for the extension.
    python main.py
  2. PyQt

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/pyqt/.
    • Run main.py with the python executable version suitable for the extension.
    python main.py
  3. Tkinter

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/tkinter/.
    • Run main.py with the python executable version suitable for the extension.
    python main.py

Windows

  1. Kivy

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/kivy/ while also extracting resources as above instructions.
    • Run main.py with the python executable version suitable for the extension.
    python main.py
  2. PyQt

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/pyqt/ while also extracting resources as above instructions.
    • Run main.py with the python executable version suitable for the extension.
    python main.py
  3. Tkinter

    • Copy pybindcef extension and cef_worker executable to pybindcef/tests/tkinter/ while also extracting resources as above instructions.
    • Run main.py with the python executable version suitable for the extension.
    python main.py

About

High-performance Python bindings for Chromium Embedded Framework (CEF)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors