How to compile with webview (linux)?

I compiled wxPython on SUSE enterprise linux a few weeks ago, and yesterday I tried using html2 widget and it failed with NotImplementedError, so I am wondering how to compile with webview. Searching the corporate linux env (I don’t have sudo access) I see some .so files with webview in their name (looks like some older versions of wx, qt, etc).

Is there a flag or step I am missing in this workflow:

# make new virtualenv, and activate it

mkdir wxpython_build
cd wxpython_build

pip install sip==6.8.5
git clone https://github.com/wxWidgets/Phoenix.git
cd Phoenix
git checkout wxPython-4.2.2
git submodule update --init --recursive
setenv CFLAGS "-I/usr/corpname/pkgs/python3/3.11.1/include/python3.11"
setenv LDFLAGS "-lpthread -ldl -lutil -lm"
python build.py --gtk2 dox etg --nodoc sip build
python build.py install
cd ../..
rm -rf wxpython_build

# install my wxpython package and run it

You need to install the WebKit development packages before building wxPython.

I don’t know what the packages are called on OpenSUSE but under Fedora it is called webkit2gtk4.1-devel.

chatGPT suggested I change my LDFLAGS to include this “webview” dir and .so file that I found in /usr/lib64

setenv LDFLAGS "-lpthread -ldl -lutil -lm -L/usr/lib64/webkit2gtk-4.0 -lwebkit2gtkinjectedbundle"

now during the build.py stage, I saw these lines, though not sure if they were present before:

These bindings will be built: _html2.
Generating the _html2 bindings...

so at least it feels like I might be close to getting this to work???!!!???

annnd just after I replied, the build crashed with:

configure:13477: checking whether the C compiler works
configure:13499: gcc -I/usr/corpname/pkgs/python3/3.11.1/include/python3.11  -lpthread -ldl -lutil -lm -L/usr/lib64/webkit2gtk-4.0 -lwebkit2gtkinjectedbundle conftest.c  >&5
/nfs/site/itools/em64t_SLES12SP5/pkgs/gcc/12.2.0/.bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lwebkit2gtkinjectedbundle: No such file or directory
collect2: error: ld returned 1 exit status
configure:13503: $? = 1
configure:13541: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "wxWidgets"
| #define PACKAGE_TARNAME "wxwidgets"
| #define PACKAGE_VERSION "3.2.6"
| #define PACKAGE_STRING "wxWidgets 3.2.6"
| #define PACKAGE_BUGREPORT "wx-dev@googlegroups.com"
| #define PACKAGE_URL ""
| #define __LINUX__ 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:13546: error: in `/nfs/site/disks/tdtic_sc/ntmccork/wxpython_build/Phoenix/build/wxbld/gtk2':
configure:13548: error: C compiler cannot create executables

here’s the dir tree that I gave GPT which helped to generate the LDFLAGS:

/usr/lib64/webkit2gtk-4.0
└── injected-bundle
    └── libwebkit2gtkinjectedbundle.so

oh, it seems GPT failed to add all the sub-dirs to the -L (injected-bundle)… added that and trying again

well after recompiling with all that… I still face NotImplementedError… so is there some way to enforce wanting webview to compile, so I will get an error rather than silent “failure” (to include it during build)

The issue you’re facing is that you need the bundled wxWidgets to be compiled with WebView support. So you may want to investigate wxWidgets’ config.log to see why it can’t find WebKit libraries.