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 28, 2022
1 parent f5b0c7b commit a41e9be
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 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 @@ -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 a41e9be

Please sign in to comment.