Some presentations of the virial theorem are mechanical (see this page by John Baez for an example). They assume that there is a system of point particles interacting only via Newtonian gravity (along with other assumptions, e.g. that the particles don't fly away to infinity), and show $\langle T \rangle = -\frac12\langle V\rangle$. The physics that goes in is just Newton's laws.
Other presentations are based on thermodynamics (see pp 81 of these notes by Mike Guidry, for example). They imagine a gas in hydrostatic equilibrium, find the pressure, and use the ideal gas law to derive the same result, $T = -\frac12 V$.
The physical assumptions that go into these seem pretty different. In the mechanical case, we have only gravitational interactions. In the thermodynamic case, the interactions aren't even specified. Presumably the gas particles are bouncing off each other according to some sort of force law, but we only actually need to know that the ideal gas law holds (and use the condition for hydrostatic equilibrium).
Although the theorems seem physically different, they have the same name and come to the same conclusion (except that the thermodynamic one doesn't need the time-averaging). How are these two versions of the virial theorem related to each other? Other than crunching through each proof separately, how can one see that they ought to give the same result?
note: I'm asking about the special case of the virial theorem described above, not the general virial theorem for more general force laws, for example