  We discuss the statistical mechanics of a system of self-gravitating
particles with an exclusion constraint in position space in a space of
dimension $d$. The exclusion constraint puts an upper bound on the density of
the system and can stabilize it against gravitational collapse. We plot the
caloric curves giving the temperature as a function of the energy and
investigate the nature of phase transitions as a function of the size of the
system and of the dimension of space in both microcanonical and canonical
ensembles. We consider stable and metastable states and emphasize the
importance of the latter for systems with long-range interactions. For $d\le
2$, there is no phase transition. For $d>2$, phase transitions can take place
between a "gaseous" phase unaffected by the exclusion constraint and a
"condensed" phase dominated by this constraint. The condensed configurations
have a core-halo structure made of a "rocky core" surrounded by an
"atmosphere", similar to a giant gaseous planet. For large systems there exist
microcanonical and canonical first order phase transitions. For intermediate
systems, only canonical first order phase transitions are present. For small
systems there is no phase transition at all. As a result, the phase diagram
exhibits two critical points, one in each ensemble. There also exist a region
of negative specific heats and a situation of ensemble inequivalence for
sufficiently large systems. By a proper interpretation of the parameters, our
results have application for the chemotaxis of bacterial populations in biology
described by a generalized Keller-Segel model including an exclusion constraint
in position space. They also describe colloids at a fluid interface driven by
attractive capillary interactions when there is an excluded volume around the
particles. Connexions with two-dimensional turbulence are also mentioned.
