Instead of the pair-by-pair approach conventionally used when defining the average stress tensor of a granular sample or of a piece of masonry, a grain-by-grain construction is proposed. Its theoretical foundation lies in the assignement, to any bounded mechanical system, of the tensor moment of its internal efforts, shortly called the internal moment of the system. In classical continuous media, the Cauchy stress is nothing but the volume-density of internal moment (or its negative, depending on the sign conventions made). This approach is not limited to systems in equilibrium; furthermore, it applies to collections involving other mechanical objects than massive grains. The pertinence of the concept is demonstrated first by numerical simulations. Secondly some mathematical procedures of smoothing and homogenisation are introduced to connect the microscopic analysis with the macroscopic continuum model. Quantitatively, in usual situations, what is obtained as stress tensor differs very little from the value resulting from traditional definitions.