Github and Discourse did some conditional installation stuff when dealing with different versions of Rails. I don't remember the specifics of Discourse, but the Github one was due to their change from Rails 2.3 to Rails 3 and the different packages they needed to include in 2.3. This case is pretty minimal though and I haven't heard of many (any?) cases outside of those two.
Py2/3 compatibility? I've never had to do this, interested what the use-case is.