Have a look at the code, it is straightforward:
(v is here the input argument).
# Define variational problem for projection
w = TestFunction(V)
Pv = TrialFunction(V)
a = ufl.inner(w, Pv)*dx
L = ufl.inner(w, v)*dx
# Assemble linear system
A, b = assemble_system(a, L, bcs=bcs,
form_compiler_parameters=form_compiler_parameters)
Then this is solved.
This is the L2-projection.