ABSTRACTSelf-gravity plays an important role in the evolution of rotationally supported systems such as protoplanetary discs, accretion discs around black holes, or galactic discs, as it can both feed turbulence and lead to gravitational fragmentation. While such systems can be studied in the shearing box approximation with high local resolution, the large density contrasts that are possible in the case of fragmentation still limit the utility of Eulerian codes with constant spatial resolution. In this paper, we present a novel self-gravity solver for the shearing box based on the TreePM method of the moving-mesh code arepo. The spatial gravitational resolution is adaptive, which is important to make full use of the quasi-Lagrangian hydrodynamical resolution of the code. We apply our new implementation to two- and three-dimensional, self-gravitating discs combined with a simple β-cooling prescription. For weak cooling we find a steady, gravito-turbulent state, while for strong cooling the formation of fragments is inevitable. To reach convergence for the critical cooling efficiency above which fragmentation occurs, we require a smoothing of the gravitational force in the two-dimensional case that mimics the stratification of the three-dimensional simulations. The critical cooling efficiency we find, β ≈ 3, as well as the box-averaged quantities characterizing the gravito-turbulent state, agrees well with various previous results in the literature. Interestingly, we observe stochastic fragmentation for β > 3, which slightly decreases the cooling efficiency required to observe fragmentation over the lifetime of a protoplanetary disc. The numerical method outlined here appears well suited to study the problem of galactic discs as well as the magnetized, self-gravitating discs.