Repository: conan-io/conan

Issue:
scm.subfolder support only one level of subfolders (not foo/baz/bar)
conan v1.6.1, Windows 10, Python 3.6

I'm moving our codebase to conan packages and encountered following error. I have to specify not single directory in `scm.subfolder` attribute, but multiple ones:
```python
scm = {
        "type": "git",
        "subfolder": "foo/baz/bar",
        "url": "auto",
        "revision": "auto",
    }
``` 
The reason is that I shouldn't change paths in `#include` directives today and I will update paths in the future.

With such recipe conan fails to build missing packages, i.e.
`conan install . --build missing` fails with an strange error:
`FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\.conan2\\gk8g1phl\\1\\foo\\baz\bar`

I think that source of this problem is this line:
https://github.com/conan-io/conan/blob/develop/conans/client/tools/scm.py#L20

Could you call `os.makedirs` instead of `os.mkdir`?

- [*] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [*] I've specified the Conan version, operating system version and any tool that can be relevant.
- [*] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:
We need to check it, but yes, it seems that changing to the ``os.makedirs()`` could fix this issue, lets have a look. Please upgrade to conan 1.7, it includes some updates to the SCM, so better check it with it too.

As a workaround, you might want to use 1 level subfolder, and then package the includes removing the unnecessary intermediate subfolders, something like:

```python
def package(self):
    self.copy("*.h", src="baz/bar", dst="include")
```
Thank you!
I've checked the issue and it exists in conan v1.7.0 too.
Yes, I'm copying .h files properly in `package` function. The problem is that header files improperly references themselves from sources in this library (like `#include <bla/foo/baz/bar/file.h` and I can't change it now) and other C++ modules references the same headers in the same way. So I have to set include paths as `self.cpp_info.includedirs = ["."]`
Well, if you want to not have the headers in the root of the package you could always try something like:

```python
def package(self):
    self.copy("*.h", src="bla/foo/baz/bar", dst="include/bla/foo/baz/bar")
    #or maybe this works, because by default it keeps relative paths:
    self.copy("*.h", src="bla/", dst="include/bla/")
def package_info(self):
     self.cpp_info.includedirs = ["include"]
```

In any case, we will have a look to the subfolder scm issue, this is just an unrelated suggestion. Thanks!
I'm able to reproduce the issue (Mac, conan 1.7, py3), @wizardsd, thanks for the detailed explanation.

Just in case anyone wants to reproduce it I've created a toy project (https://github.com/jgsogo/conan-issue3423/blob/master/conanfile.py), uploaded it to a remote and then: 

```bash
conan remote add jgsogo https://api.bintray.com/conan/jgsogo/conan-packages
conan install issue3423/0.0@issue/test --build=issue3423
```

output:

```
ERROR: 
	FileNotFoundError: [Errno 2] No such file or directory: '<edited>/.conan/data/issue3423/0.0/issue/test/source/hello/to/you'
```
With the modification you suggested, it works 👍. I will check a little bit more just in case something else is affected.

Thanks!


Resolving patch:
diff --git a/conans/client/tools/scm.py b/conans/client/tools/scm.py
--- a/conans/client/tools/scm.py
+++ b/conans/client/tools/scm.py
@@ -17,7 +17,7 @@ def __init__(self, folder=None, verify_ssl=True, username=None, password=None, f
                  runner=None):
         self.folder = folder or os.getcwd()
         if not os.path.exists(self.folder):
-            os.mkdir(self.folder)
+            os.makedirs(self.folder)
         self._verify_ssl = verify_ssl
         self._force_eng = force_english
         self._username = username


Test patch:
diff --git a/conans/test/remote/scm_nested_subfolder.py b/conans/test/remote/scm_nested_subfolder.py
new file mode 100644
--- /dev/null
+++ b/conans/test/remote/scm_nested_subfolder.py
@@ -0,0 +1,39 @@
+import unittest
+from conans.test.utils.tools import TestServer, TestClient, create_local_git_repo
+from conans.client.tools.scm import Git
+
+
+class SCMNestedSubfolderTest(unittest.TestCase):
+
+    # Testing as of issue #3423: https://github.com/conan-io/conan/issues/3423
+    def basic_test(self):
+        server = TestServer()
+        servers = {"default": server}
+
+        # Create a project with git
+        files = {'conanfile.py': """from conans import ConanFile
+class MyPkg(ConanFile):
+    name= "package"
+    version = "1.0"
+
+    scm = {
+        "type": "git",
+        "subfolder": "hello/to/you",
+        "url": "auto",
+        "revision": "auto"
+    }
+
+"""}
+        path, _ = create_local_git_repo(files)
+        client = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})
+        git = Git(client.current_folder)
+        git.clone(path)
+
+        # Upload to 'remote'
+        client.run("export . lasote/stable")
+        client.run("upload package/1.0@lasote/stable")
+
+        # Consume the project
+        client = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})
+        error = client.run("install package/1.0@lasote/stable --build=package")
+        self.assertFalse(error)