Backport of 7d1b69dbe7f72ac04d2513f0468fe2146231b286 from master
Thanks Tim Graham for polishing the patch, updating the tests, and writing documentation. Thanks Carl Meyer for shepherding the DEP.