Populating the galaxy with pulsars I: stellar and binary evolution