Repository: conan-io/conan

Issue:
[Bug] Error on editable package if 'build_folder' is in layout file
Since the arrival of workspaces, a layout file can contain a `build_folder` section. Nevertheless, this layout fails if used with an editable package (not inside a workspace). Test provided by @lasote ([source](https://github.com/conan-io/conan/compare/develop...lasote:test/graph_info_crash?expand=1)):

```python
    def test_editable_crash(self):
        ref = ConanFileReference.loads("lib/1.0@conan/stable")
        client = TurboTestClient()
        client.create(ref)
        save(os.path.join(client.current_folder, "mylayout"),
             textwrap.dedent("""
                [build_folder]
                build
                """))
        client.run("editable add . {} --layout mylayout".format(ref))
        client.change_to_clean_folder()
        ref2 = ConanFileReference.loads("lib2/1.0@conan/stable")
        conanfile2 = GenConanfile().with_requirement(ref)
        client.create(ref2, conanfile=conanfile2)
```

The problem is that we get to the `BinaryInstaller::_handle_node_editable` function without a `graph_info`, but with a `build_folder` in the layout:

```python
def _handle_node_editable(self, node, graph_info):
    ...
    if build_folder is not None:
        ...
        graph_info.save(build_folder)
```






Discussion:
For `v1.15` it could be enough to handle the exception and keep running, but we need to think a good solution for it.

Resolving patch:
diff --git a/conans/client/installer.py b/conans/client/installer.py
--- a/conans/client/installer.py
+++ b/conans/client/installer.py
@@ -421,7 +421,7 @@ def _build_package(self, node, pref, output, keep_build, remotes):
         assert pref.id, "Package-ID without value"
 
         # It is necessary to complete the sources of python requires, which might be used
-        for name, python_require in conanfile.python_requires.items():
+        for python_require in conanfile.python_requires.values():
             assert python_require.ref.revision is not None, \
                 "Installer should receive python_require.ref always"
             complete_recipe_sources(self._remote_manager, self._cache,
diff --git a/conans/client/manager.py b/conans/client/manager.py
--- a/conans/client/manager.py
+++ b/conans/client/manager.py
@@ -77,7 +77,7 @@ def install(self, ref_or_path, install_folder, graph_info, remotes=None, build_m
         installer = BinaryInstaller(self._cache, self._user_io.out, self._remote_manager,
                                     recorder=self._recorder,
                                     hook_manager=self._hook_manager)
-        installer.install(deps_graph, remotes, keep_build=keep_build)
+        installer.install(deps_graph, remotes, keep_build=keep_build, graph_info=graph_info)
 
         if manifest_folder:
             manifest_manager = ManifestManager(manifest_folder, user_io=self._user_io,


Test patch:
diff --git a/conans/test/functional/editable/layouts_test.py b/conans/test/functional/editable/layouts_test.py
--- a/conans/test/functional/editable/layouts_test.py
+++ b/conans/test/functional/editable/layouts_test.py
@@ -6,6 +6,8 @@
 import unittest
 
 from conans.model.editable_layout import LAYOUTS_FOLDER
+from conans.model.ref import ConanFileReference
+from conans.test.utils.conanfile import TestConanFile
 from conans.test.utils.test_files import temp_folder
 from conans.test.utils.tools import TestClient
 from conans.util.files import load, save_files, save
@@ -13,6 +15,23 @@
 
 class LayoutTest(unittest.TestCase):
 
+    def test_editable_crash(self):
+        ref = ConanFileReference.loads("lib/1.0@conan/stable")
+        client = TestClient()
+        layout = textwrap.dedent("""
+                    [build_folder]
+                    build
+                    """)
+        client.save({"conanfile.py": TestConanFile("lib", "1.0"),
+                     "mylayout": layout})
+        client.run("editable add . {} --layout mylayout".format(ref))
+        client2 = TestClient(base_folder=client.base_folder)
+        client2.save({"conanfile.py": TestConanFile("app", "1.0",
+                                                    requires=["lib/1.0@conan/stable"])})
+        client2.run("create . user/testing")
+        graph_info = os.path.join(client.current_folder, "build", "graph_info.json")
+        self.assertTrue(os.path.exists(graph_info))
+
     def test_missing_wrong_layouts(self):
         client = TestClient()
         conanfile = textwrap.dedent("""
@@ -202,7 +221,8 @@ class Pkg(ConanFile):
         client2.run("install . -g cmake -s build_type=Debug", assert_error=True)
         self.assertIn("ERROR: Error parsing layout file '{}' (for reference "
                       "'mytool/0.1@user/testing')\n'settings.build_type' doesn't exist".format(
-            os.path.join(client.current_folder, 'layout')), client2.out)
+                          os.path.join(client.current_folder, 'layout')),
+                      client2.out)
 
         # Now add settings to conanfile
         client.save({"conanfile.py": conanfile.replace("pass", 'settings = "build_type"')})
diff --git a/conans/test/utils/tools.py b/conans/test/utils/tools.py
--- a/conans/test/utils/tools.py
+++ b/conans/test/utils/tools.py
@@ -848,7 +848,7 @@ def run(self, command_line, user_io=None, assert_error=False):
 
     def run_command(self, command):
         self.all_output += str(self.out)
-        self.init_dynamic_vars() # Resets the output
+        self.init_dynamic_vars()  # Resets the output
         return self.runner(command, cwd=self.current_folder)
 
     def save(self, files, path=None, clean_first=False):
@@ -858,6 +858,7 @@ def save(self, files, path=None, clean_first=False):
         path = path or self.current_folder
         if clean_first:
             shutil.rmtree(self.current_folder, ignore_errors=True)
+        files = {f: str(content) for f, content in files.items()}
         save_files(path, files)
         if not files:
             mkdir(self.current_folder)