mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Which was added in https://github.com/pytorch/pytorch/issues/16412. Also make some CUDNN_* CMake variables to be build options so as to avoid direct reading using `$ENV` from environment variables from CMake scripts. Pull Request resolved: https://github.com/pytorch/pytorch/pull/24044 Differential Revision: D16783426 Pulled By: ezyang fbshipit-source-id: cb196b0013418d172d0d36558995a437bd4a3986
17 lines
498 B
Python
17 lines
498 B
Python
import os
|
|
import sys
|
|
|
|
|
|
def which(thefile):
|
|
path = os.environ.get("PATH", os.defpath).split(os.pathsep)
|
|
for d in path:
|
|
fname = os.path.join(d, thefile)
|
|
fnames = [fname]
|
|
if sys.platform == 'win32':
|
|
exts = os.environ.get('PATHEXT', '').split(os.pathsep)
|
|
fnames += [fname + ext for ext in exts]
|
|
for name in fnames:
|
|
if os.access(name, os.F_OK | os.X_OK) and not os.path.isdir(name):
|
|
return name
|
|
return None
|