py31compat.py 600 B

12345678910111213141516171819202122
  1. import os
  2. import errno
  3. import sys
  4. def _makedirs_31(path, exist_ok=False):
  5. try:
  6. os.makedirs(path)
  7. except OSError as exc:
  8. if not exist_ok or exc.errno != errno.EEXIST:
  9. raise
  10. # rely on compatibility behavior until mode considerations
  11. # and exists_ok considerations are disentangled.
  12. # See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663
  13. needs_makedirs = (
  14. sys.version_info < (3, 2, 5) or
  15. (3, 3) <= sys.version_info < (3, 3, 6) or
  16. (3, 4) <= sys.version_info < (3, 4, 1)
  17. )
  18. makedirs = _makedirs_31 if needs_makedirs else os.makedirs