Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
`cmake_cache_vars` does not exist everywhere, create global function to
take care of it
  • Loading branch information
malfet committed Oct 29, 2022
1 parent f6c8b4f commit 4e8ae96
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions setup.py
Expand Up @@ -762,18 +762,22 @@ def run(self):
super().run()


def get_cmake_cache_vars():
try:
return defaultdict(lambda: False, cmake.get_cmake_cache_variables())
except FileNotFoundError:
# CMakeCache.txt does not exist. Probably running "python setup.py clean" over a clean directory.
return defaultdict(lambda: False)


def configure_extension_build():
r"""Configures extension build options according to system environment and user's choice.
Returns:
The input to parameters ext_modules, cmdclass, packages, and entry_points as required in setuptools.setup.
"""

try:
cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables())
except FileNotFoundError:
# CMakeCache.txt does not exist. Probably running "python setup.py clean" over a clean directory.
cmake_cache_vars = defaultdict(lambda: False)
cmake_cache_vars = get_cmake_cache_vars()

################################################################################
# Configure compile flags
Expand Down Expand Up @@ -1060,7 +1064,7 @@ def main():
'include/ATen/native/quantized/*.h',
'include/ATen/native/quantized/cpu/*.h',
'include/ATen/quantized/*.h',
'include/caffe2/serialization/*.h',
'include/caffe2/serialize/*.h',
'include/c10/*.h',
'include/c10/macros/*.h',
'include/c10/core/*.h',
Expand Down Expand Up @@ -1162,7 +1166,7 @@ def main():
'utils/model_dump/*.mjs',
]

if cmake_cache_vars['BUILD_CAFFE2']:
if get_cmake_cache_vars()['BUILD_CAFFE2']:
torch_package_data.extend([
'include/caffe2/**/*.h',
'include/caffe2/utils/*.h',
Expand Down

0 comments on commit 4e8ae96

Please sign in to comment.