diff --git a/pybindmagic/__init__.py b/pybindmagic/__init__.py index d9015e6..13579b0 100644 --- a/pybindmagic/__init__.py +++ b/pybindmagic/__init__.py @@ -174,8 +174,9 @@ def cpp(line, cell, *what): # otherwise we import all names that don't begin with _ names = [x for x in mdl.__dict__ if not x.startswith("_")] except Exception as e: - with open(os.path.join(cmake_path,"CMakeLists.txt"), 'w') as f: - f.write(cmake) + if cmake_path is not None: + with open(os.path.join(cmake_path,"CMakeLists.txt"), 'w') as f: + f.write(cmake) if os.path.exists(os.path.join(path,f"{name}.cpp")): os.remove(os.path.join(path,f"{name}.cpp")) raise e