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