Segmentation fault when running custom built bpy

First off, note that the standalone bpy is experimental and might therefor not work at all.

That said I just built a bpy-only version of the master branch (so that’s code for the upcoming 2.90 version of Blender) on Arch. When I import bpy in Python 3.8.2 I also get a segfault, which appears to be caused by a null pointer during OpenGL context creation:

#0  0x0000000000000000 in ?? ()
#1  0x00007f5f7762ba27 in GPU_context_create () from /home/melis/software/blender-bpy-git/bpy.so
#2  0x00007f5f757ced24 in DRW_opengl_context_create () from /home/melis/software/blender-bpy-git/bpy.so
#3  0x00007f5f756fc8f9 in WM_init_opengl () from /home/melis/software/blender-bpy-git/bpy.so
#4  0x00007f5f757cfd37 in DRW_render_to_image () from /home/melis/software/blender-bpy-git/bpy.so
#5  0x00007f5f7714ebd4 in RE_engine_render () from /home/melis/software/blender-bpy-git/bpy.so
#6  0x00007f5f77158a11 in do_render () from /home/melis/software/blender-bpy-git/bpy.so
#7  0x00007f5f7715bba8 in do_render_all_options () from /home/melis/software/blender-bpy-git/bpy.so
#8  0x00007f5f7715c2c2 in RE_RenderFrame () from /home/melis/software/blender-bpy-git/bpy.so

This might be because there’s no GUI active (which is drawn using OpenGL) and therefore no OpenGL context and rendering is available at all, meaning EEVEE might not be usable when using Blender through the bpy module. I guess @ideasman42 would know if this is the case?

Switching to Cycles and then rendering does work though:

Python 3.8.2 (default, Apr  8 2020, 14:31:25) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy
>>> bpy.context.scene.render.engine = 'CYCLES'
>>> bpy.ops.render.render(write_still=True)
...
Fra:1 Mem:48.36M (0.00M, Peak 48.90M) | Time:00:22.42 | Remaining:00:00.01 | Mem:1.65M, Peak:2.04M | Scene, View Layer | Rendered 509/510 Tiles, Sample 128/128
Fra:1 Mem:48.25M (0.00M, Peak 48.90M) | Time:00:22.45 | Mem:1.53M, Peak:2.04M | Scene, View Layer | Rendered 510/510 Tiles
Fra:1 Mem:48.25M (0.00M, Peak 48.90M) | Time:00:22.45 | Mem:1.53M, Peak:2.04M | Scene, View Layer | Finished
Fra:1 Mem:46.64M (0.00M, Peak 48.90M) | Time:00:22.45 | Sce: Scene Ve:0 Fa:0 La:0
Saved: '/tmp/.png'
 Time: 00:22.97 (Saving: 00:00.51)

{'FINISHED'}
>>> 

So perhaps try switching to Cycles explicitly and see if that helps.