Repository: conan-io/conan-center-index

Issue:
[package] protobuf/3.21.4: Outdated required_conan_version
### Package and Environment Details

The import statement [in the recipe](https://github.com/conan-io/conan-center-index/blob/81d3a9ec98fe0cc86f1033d0567a97db014a0750/recipes/protobuf/all/conanfile.py#L1) refers to `rmdir` and `rm` from conan file tools. The two methods are newly available in conan 1.47.0 and 1.50.0, respectively. Thus, `required_conan_version` has to be updated accordingly (currently stating `>=1.43.0`).


### Conan profile

_No response_

### Steps to reproduce

* Try to use the recipe with conan < 1.47.0

### Logs

<details><summary>Click to expand log</summary>

```
>>> from conan.tools.files import rm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'rm' from 'conan.tools.files' (/usr/local/lib/python3.10/dist-packages/conan/tools/files/__init__.py)
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py
--- a/recipes/protobuf/all/conanfile.py
+++ b/recipes/protobuf/all/conanfile.py
@@ -1,18 +1,17 @@
 from conan.tools.files import rename, get, apply_conandata_patches, replace_in_file, rmdir, rm
-from conan.tools.microsoft import msvc_runtime_flag
+from conan.tools.microsoft import msvc_runtime_flag, is_msvc
 from conan.tools.scm import Version
 from conan.tools.build import cross_building
 from conan.errors import ConanInvalidConfiguration
 from conan import ConanFile
 from conans import CMake
-# TODO: Update to conan.tools.apple after 1.51.3
-from conans.tools import is_apple_os
+from conan.tools.apple import is_apple_os
 
 import functools
 import os
 import textwrap
 
-required_conan_version = ">=1.43.0"
+required_conan_version = ">=1.51.3"
 
 
 class ProtobufConan(ConanFile):
@@ -52,10 +51,6 @@ def _source_subfolder(self):
     def _build_subfolder(self):
         return "build_subfolder"
 
-    @property
-    def _is_msvc(self):
-        return str(self.settings.compiler) in ["Visual Studio", "msvc"]
-
     @property
     def _is_clang_cl(self):
         return self.settings.compiler == 'clang' and self.settings.os == 'Windows'
@@ -126,7 +121,7 @@ def _configure_cmake(self):
             cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True
         if self._can_disable_rtti:
             cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti
-        if self._is_msvc or self._is_clang_cl:
+        if is_msvc(self) or self._is_clang_cl:
             runtime = msvc_runtime_flag(self)
             if not runtime:
                 runtime = self.settings.get_safe("compiler.runtime")
@@ -177,7 +172,7 @@ def _patch_sources(self):
         # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf
         # (even with virtualrunenv, this fix might be required due to SIP)
         # Only works with cmake, cmake_find_package or cmake_find_package_multi generators
-        if is_apple_os(self.settings.os):
+        if is_apple_os(self):
             replace_in_file(self,
                 protobuf_config_cmake,
                 "add_custom_command(",
@@ -246,7 +241,7 @@ def package_info(self):
         ]
         self.cpp_info.set_property("cmake_build_modules", build_modules)
 
-        lib_prefix = "lib" if (self._is_msvc or self._is_clang_cl) else ""
+        lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else ""
         lib_suffix = "d" if self.settings.build_type == "Debug" and self.options.debug_suffix else ""
 
         # libprotobuf


Test patch: