Repository: conan-io/conan-center-index

Issue:
[package] wayland/all: incompatible with latest (1.52.0) Conan version
### Package and Environment Details

* Package Name/Version: **wayland/1.20.0**
* Conan version: **conan 1.52.0**

### Conan profile

_No response_

### Steps to reproduce

conan export recipes/wayland/all wayland/1.20.0@

### Logs

<details><summary>Click to expand log</summary>

```
File "recipes/wayland/all/conanfile.py", line 5, in <module>
    from conan.tools.gnu.pkgconfigdeps.pc_files_creator import get_pc_files_and_content
ModuleNotFoundError: No module named 'conan.tools.gnu.pkgconfigdeps.pc_files_creator'; 'conan.tools.gnu.pkgconfigdeps' is not a package
```

</details>



Discussion:
incompatibility caused most likely with this feature:
https://github.com/conan-io/conan/pull/11955

@franramirez688 do you have ideas how one could support `<1.52.0` and the latest?
It was not part of official conan API and shouldn't have been imported in the first place in `wayland` recipe. But yes, let's see how to find a robust workaround.

I think PkgConfigDeps can allow to generate .pc files for tool_requires since conan 1.52.0, and it comes from https://github.com/conan-io/conan/issues/11710 which actually is an issue created due to this fragile workaround in wayland recipe.
@dornbirndevelops is, as @SpaceIm was saying, a workaround using some PkgConfigDeps internal functions which were not part of the public API.
In the next Conan 1.52, it has to be feasible to make it run without using any private function from PkgConfigDeps. After all, I'll be aware of the issue/recipe to double-check that it works.
How it could come to this state? Don't you make a minimal test with conan export for each recipe in conan-center-index before releasing a new version of conan client?...
Hi @AndreyMlashkin - the guidelines for importing tools from `conan.tools` are in the documentation: https://docs.conan.io/en/latest/reference/conanfile/tools.html, and every publicly available `yyy` tool is explicitly made available as `conan.tools.xxx.yyy`, and is documented as such. Anything that is any further levels down or not documented is not considered public API. This was also flagged by @franramirez688  on a related PR here: https://github.com/conan-io/conan-center-index/pull/11636#discussion_r930240901. When releasing Conan, we go to great lengths to retain backwards compatibility of the publicly documented APIs. 

I apologise that during the review process for the changes in the wayland recipe this was not flagged. Reviewers in conan-center-index deal with a high level of requests, and we try to do our best. 
We should be able to patch this until Conan Center starts using Conan 1.52. I know the `xkbcommon` package has to do a similar workaround, but it was done differently [there](https://github.com/conan-io/conan-center-index/blob/master/recipes/xkbcommon/all/conanfile.py#L78).

Resolving patch:
diff --git a/recipes/wayland/all/conanfile.py b/recipes/wayland/all/conanfile.py
--- a/recipes/wayland/all/conanfile.py
+++ b/recipes/wayland/all/conanfile.py
@@ -1,8 +1,7 @@
 from conan import ConanFile
 from conan.errors import ConanInvalidConfiguration
 from conan.tools.build import cross_building
-from conan.tools.files import copy, get, mkdir, replace_in_file, rmdir, save
-from conan.tools.gnu.pkgconfigdeps.pc_files_creator import get_pc_files_and_content
+from conan.tools.files import copy, get, replace_in_file, rmdir
 from conan.tools.layout import basic_layout
 from conan.tools.meson import Meson, MesonToolchain
 from conan.tools.scm import Version
@@ -82,21 +81,20 @@ def generate(self):
         tc.project_options["documentation"] = False
         if Version(self.version) >= "1.18.91":
             tc.project_options["scanner"] = True
-
-            # Generate PC files for the tool_requires wayland package to ensure wayland-scanner is found for build machine.
-            if cross_building(self):
-                native_generators_folder = os.path.join(self.generators_folder, "native")
-                mkdir(self, native_generators_folder)
-                for target in ["wayland", "expat", "libxml2", "libiconv"]:
-                    for pc_name, pc_content in get_pc_files_and_content(self, self.dependencies.build[target]).items():
-                        save(self, os.path.join(native_generators_folder, pc_name), pc_content)
-                tc.project_options["build.pkg_config_path"] = native_generators_folder
         tc.generate()
 
     def _patch_sources(self):
         replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
                         "subdir('tests')", "#subdir('tests')")
 
+        if cross_building(self):
+            replace_in_file(self, f"{self.source_folder}/src/meson.build",
+                            "scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())",
+                                "# scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())")
+            replace_in_file(self, f"{self.source_folder}/src/meson.build",
+                            "wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))",
+                                "wayland_scanner_for_build = find_program('wayland-scanner')")
+
     def build(self):
         self._patch_sources()
         meson = Meson(self)


Test patch: