Repository: conan-io/conan-center-index

Issue:
[package] Ninja/1.11.0; does not work with Conan 2.0 due to use of self.env_info
### Description

Attempting to build Ninja using the updated 2.0 compatible recipe results in the following error:

> ERROR: ninja/1.11.0: Error in package_info() method, line 50
>         self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
>         AttributeError: 'NinjaConan' object has no attribute 'env_info'



### Package and Environment Details

* Package Name/Version: **ninja/1.11.0**
* Operating System+version: **Debian 10.3**
* Compiler+version: **GCC 8**
* Conan version: **conan 2.0.0beta4**
* Python version: **Python 3.7.3**


### Conan profile

-------- Input profiles --------
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux

### Steps to reproduce

conan-2.0 create . --version 1.11.0

### Logs

<details><summary>Click to expand log</summary>

```
Exporting the recipe
ninja/1.11.0: Exporting package recipe
ninja/1.11.0 exports: File 'conandata.yml' found. Exporting it...
ninja/1.11.0: Copied 1 '.yml' file: conandata.yml
ninja/1.11.0 exports: Copied 1 '.yml' file: conandata.yml
ninja/1.11.0: Using the exported files summary hash as the recipe revision: 56040fc40f098c10d50971e6e090c634
ninja/1.11.0: A new conanfile.py version was exported
ninja/1.11.0: Folder: /home/marc/.conan2/p/2a66362d34041272/e
ninja/1.11.0: Exported revision: 56040fc40f098c10d50971e6e090c634

-------- Input profiles --------
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux


-------- Computing dependency graph --------
Graph root
    virtual
Requirements
    ninja/1.11.0#56040fc40f098c10d50971e6e090c634 - Cache

-------- Computing necessary packages --------
ninja/1.11.0: Forced build from source
Requirements
    ninja/1.11.0#56040fc40f098c10d50971e6e090c634:3593751651824fb813502c69c971267624ced41a - Build

-------- Installing packages --------

-------- Installing (downloading, building) binaries... --------
ninja/1.11.0: Calling source() in /home/marc/.conan2/p/2a66362d34041272/s/src
Downloading v1.11.0.tar.gz

ninja/1.11.0: Copying sources to build folder
ninja/1.11.0: Building your package in /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b
ninja/1.11.0: Calling generate()
ninja/1.11.0: Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
ninja/1.11.0: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
ninja/1.11.0: Aggregating env generators
ninja/1.11.0: Calling build()
ninja/1.11.0: CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/src"
ninja/1.11.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/src"
-- Using Conan toolchain: /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 14 with extensions ON
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IPO / LTO enabled
-- Performing Test flag_no_deprecated
-- Performing Test flag_no_deprecated - Success
-- Performing Test flag_color_diag
-- Performing Test flag_color_diag - Success
CMake Warning at CMakeLists.txt:49 (message):
  re2c was not found; changes to src/*.in.cc will not affect your build.


-- Looking for fork
-- Looking for fork - found
-- Looking for pipe
-- Looking for pipe - found
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_POLICY_DEFAULT_CMP0091


-- Build files have been written to: /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release
ninja/1.11.0: CMake command: cmake --build "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release" -- -j8
ninja/1.11.0: RUN: cmake --build "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release" -- -j8
Scanning dependencies of target libninja
Scanning dependencies of target libninja-re2c
[  6%] Building CXX object CMakeFiles/libninja-re2c.dir/src/lexer.cc.o
[  6%] Building CXX object CMakeFiles/libninja-re2c.dir/src/depfile_parser.cc.o
[ 19%] Building CXX object CMakeFiles/libninja.dir/src/build_log.cc.o
[ 19%] Building CXX object CMakeFiles/libninja.dir/src/clean.cc.o
[ 19%] Building CXX object CMakeFiles/libninja.dir/src/clparser.cc.o
[ 22%] Building CXX object CMakeFiles/libninja.dir/src/build.cc.o
[ 22%] Building CXX object CMakeFiles/libninja.dir/src/dyndep.cc.o
[ 25%] Building CXX object CMakeFiles/libninja.dir/src/dyndep_parser.cc.o
[ 29%] Building CXX object CMakeFiles/libninja.dir/src/debug_flags.cc.o
[ 32%] Building CXX object CMakeFiles/libninja.dir/src/deps_log.cc.o
[ 32%] Built target libninja-re2c
[ 35%] Building CXX object CMakeFiles/libninja.dir/src/disk_interface.cc.o
[ 38%] Building CXX object CMakeFiles/libninja.dir/src/edit_distance.cc.o
[ 45%] Building CXX object CMakeFiles/libninja.dir/src/graph.cc.o
[ 45%] Building CXX object CMakeFiles/libninja.dir/src/eval_env.cc.o
[ 48%] Building CXX object CMakeFiles/libninja.dir/src/graphviz.cc.o
[ 51%] Building CXX object CMakeFiles/libninja.dir/src/json.cc.o
[ 54%] Building CXX object CMakeFiles/libninja.dir/src/line_printer.cc.o
[ 58%] Building CXX object CMakeFiles/libninja.dir/src/manifest_parser.cc.o
[ 61%] Building CXX object CMakeFiles/libninja.dir/src/metrics.cc.o
[ 64%] Building CXX object CMakeFiles/libninja.dir/src/missing_deps.cc.o
[ 67%] Building CXX object CMakeFiles/libninja.dir/src/parser.cc.o
[ 70%] Building CXX object CMakeFiles/libninja.dir/src/state.cc.o
[ 74%] Building CXX object CMakeFiles/libninja.dir/src/status.cc.o
[ 77%] Building CXX object CMakeFiles/libninja.dir/src/string_piece_util.cc.o
[ 80%] Building CXX object CMakeFiles/libninja.dir/src/util.cc.o
[ 83%] Building CXX object CMakeFiles/libninja.dir/src/version.cc.o
[ 87%] Building CXX object CMakeFiles/libninja.dir/src/subprocess-posix.cc.o
[ 87%] Built target libninja
[ 90%] Generating build/browse_py.h
Scanning dependencies of target ninja
[ 96%] Building CXX object CMakeFiles/ninja.dir/src/ninja.cc.o
[ 96%] Building CXX object CMakeFiles/ninja.dir/src/browse.cc.o
[100%] Linking CXX executable ninja
[100%] Built target ninja
ninja/1.11.0: Package '3593751651824fb813502c69c971267624ced41a' built
ninja/1.11.0: Build folder /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release
ninja/1.11.0: Generated conaninfo.txt
ninja/1.11.0: Generating the package
ninja/1.11.0: Temporary package folder /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p
ninja/1.11.0: Calling package()
ninja/1.11.0: Copied 1 file: COPYING
ninja/1.11.0: CMake command: cmake --install "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release" --prefix "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p"
ninja/1.11.0: RUN: cmake --install "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/b/build/Release" --prefix "/home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p"
-- Install configuration: "Release"
-- Installing: /home/marc/.conan2/p/tmp/4dda2b7efb683f8b/p/bin/ninja
ninja/1.11.0 package(): Packaged 2 files: ninja, COPYING
ninja/1.11.0: Package '3593751651824fb813502c69c971267624ced41a' created
ninja/1.11.0: Created package revision 0dc74834457ae37183757460a6996342
ninja/1.11.0: Full package reference: ninja/1.11.0#56040fc40f098c10d50971e6e090c634:3593751651824fb813502c69c971267624ced41a#0dc74834457ae37183757460a6996342
ninja/1.11.0: Package folder /home/marc/.conan2/p/80cb94ded933808a/p
ERROR: ninja/1.11.0: Error in package_info() method, line 50
        self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
        AttributeError: 'NinjaConan' object has no attribute 'env_info'```


</details>


Discussion:

Resolving patch:
diff --git a/recipes/ninja/all/conanfile.py b/recipes/ninja/all/conanfile.py
--- a/recipes/ninja/all/conanfile.py
+++ b/recipes/ninja/all/conanfile.py
@@ -1,13 +1,15 @@
-from conan import ConanFile
+from conan import ConanFile, conan_version
 from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
 from conan.tools.files import copy, get
+from conan.tools.scm import Version
 import os
 
-required_conan_version = ">=1.46.0"
+required_conan_version = ">=1.52.0"
 
 
 class NinjaConan(ConanFile):
     name = "ninja"
+    package_type = "application"
     description = "Ninja is a small build system with a focus on speed"
     license = "Apache-2.0"
     url = "https://github.com/conan-io/conan-center-index"
@@ -47,5 +49,6 @@ def package_info(self):
         self.conf_info.define("tools.cmake.cmaketoolchain:generator", "Ninja")
 
         # TODO: to remove in conan v2
-        self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
-        self.env_info.CONAN_CMAKE_GENERATOR = "Ninja"
+        if Version(conan_version).major < 2:
+            self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
+            self.env_info.CONAN_CMAKE_GENERATOR = "Ninja"


Test patch: