From Papal Encyclicals Online [excerpt]:
For these reasons, clerics who in their diocese or religious who in another community have sinned gravely against chastity with another person are not to be admitted with a view to the priesthood, even on a trial basis, unless there be clear evidence of excusing causes or of circumstances which can at least notably diminish responsibility in conscience (Circular Letter of S. C. of the Sacraments, n. 16; Canon Law Digest, 4, p. 314).
Advantage to religious vows and ordination should be barred to those who are afflicted with evil tendencies to homosexuality or pederasty, since for them the common life and the priestly ministry would constitute serious dangers.
5. Very special investigation is needed for those students who, although they have hitherto been free of formal sins against chastity, nevertheless suffer from morbid or abnormal sexuality, especially sexual hyperesthesia or an erotic bent of nature, to whom religious celibacy would be a continual act of heroism and a trying martyrdom. For chastity, in so far as it implies abstinence from sexual pleasure, not only becomes very difficult for many people but the very state of celibacy and the consequent loneliness and separation from one’s family becomes so difficult for certain individuals gifted with excessive sensitivity and tenderness, that they are not fit subjects for the religious life. This question should perhaps receive more careful attention from novice masters and superiors of scholasticates than from confessors since such natural tendencies do not come out so clearly in confession as in the common life and daily contact.