Density-functional theory for ensembles defined by fixed weights and f
ractional occupation numbers is derived using a Lagrange-multiplier ve
rsion of the constrained-search procedure. This is related to an adiab
atic connection between a generalized Kohn-Sham ensemble for nonintera
cting electrons and a minimum-energy ensemble including the electronic
Coulomb interaction. Using this formalism, it is shown that discontin
uous changes of the chemical potential of a finite electronic system r
esult from constraints on density variations imposed by Fermi statisti
cs. Such discontinuities do not exclude the possibility of defining an
exchange-correlation energy functional that is free of derivative dis
continuities for unconstrained density variations.