Repository: mesonbuild/meson

Issue:
Python 3.6 regression for as_system() on cmake subproject dependency objects
**Describe the bug**
I need to change the include_type for cmake subproject dependencies to 'system'.  Meson 0.54.3 using Python3.6 (Centos 7) this worked correctly.  However after upgrading to Meson 0.55 I get a "TypeError: cannot deepcopy this pattern object" exception.  If I upgrade to Python 3.7 this goes away.  However, Meson is stated to be supported in Python 3.5+.

**To Reproduce**
meson.build
```
project('cmake_dep_regression','cpp')
cmake = import('cmake')
xerces_dep = cmake.subproject('xerces-c').dependency('xerces-c').as_system('system')
exe1 = executable('main', ['main.cpp'], dependencies: [xerces_dep])
```
main.cpp
```
#include <iostream>
#include <cmMod.hpp>

using namespace std;

int main(void) {
  cmModClass obj("Hello");
  cout << obj.getStr() << endl;
  return 0;
}
```
xerces-c.wrap
```
[wrap-git]
url = https://github.com/apache/xerces-c.git
revision = v3.2.2
```

**Expected behavior**
I expect the build to be successful (no traceback) and for the xerces header files to be -isystem included in the main.cpp compile step (see compile_commands.json).

**system parameters**
* Plain native build
* CentOS 7.8
* Python 3.6.8 (fails) and Python 3.7.6 (works)
* meson 0.55.0
* ninja 1.9.0



Discussion:

Resolving patch:
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -252,6 +252,16 @@ def __init__(self, version, incdirs, compile_args, link_args, libraries,
         self.ext_deps = ext_deps
         self.variables = variables
 
+    def __deepcopy__(self, memo: dict) -> 'InternalDependency':
+        result = self.__class__.__new__(self.__class__)
+        memo[id(self)] = result
+        for k, v in self.__dict__.items():
+            if k in ['libraries', 'whole_libraries']:
+                setattr(result, k, copy.copy(v))
+            else:
+                setattr(result, k, copy.deepcopy(v, memo))
+        return result
+
     def get_pkgconfig_variable(self, variable_name, kwargs):
         raise DependencyException('Method "get_pkgconfig_variable()" is '
                                   'invalid for an internal dependency')


Test patch:
diff --git a/run_project_tests.py b/run_project_tests.py
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -1115,16 +1115,15 @@ def check_format():
                       '.build',
                       '.md',
                       }
+    skip_dirs = {
+        '.dub',                         # external deps are here
+        '.pytest_cache',
+        'meson-logs', 'meson-private',
+        '.eggs', '_cache',              # e.g. .mypy_cache
+        'venv',                         # virtualenvs have DOS line endings
+    }
     for (root, _, filenames) in os.walk('.'):
-        if '.dub' in root: # external deps are here
-            continue
-        if '.pytest_cache' in root:
-            continue
-        if 'meson-logs' in root or 'meson-private' in root:
-            continue
-        if '__CMake_build' in root:
-            continue
-        if '.eggs' in root or '_cache' in root:  # e.g. .mypy_cache
+        if any([x in root for x in skip_dirs]):
             continue
         for fname in filenames:
             file = Path(fname)
@@ -1248,6 +1247,7 @@ def get_version(t: dict) -> str:
         options.extra_args += ['--cross-file', options.cross_file]
 
     print('Meson build system', meson_version, 'Project Tests')
+    print('Using python', sys.version.split('\n')[0])
     setup_commands(options.backend)
     detect_system_compiler(options)
     print_tool_versions()