Backport pip handling from flatter.