Repository: conan-io/conan
Pull request #17257 (2024-10-30 21:43:11)

raise when new CMakeDeps doesn't find lib location
Changelog: Omit
Docs: Omit

Close https://github.com/conan-io/conan/issues/17258

For https://github.com/conan-io/conan/issues/17256



Patch:
diff --git a/conan/__init__.py b/conan/__init__.py
index 01068d712..b824fa904 100644
--- a/conan/__init__.py
+++ b/conan/__init__.py
@@ -1,6 +1,5 @@
 from conans.model.conan_file import ConanFile
 from conan.tools.scm import Version as _Version
-from conans import __version__
-
 
+__version__ = '2.10.0-dev'
 conan_version = _Version(__version__)
diff --git a/conan/api/conan_api.py b/conan/api/conan_api.py
index 160492367..cfa9740f9 100644
--- a/conan/api/conan_api.py
+++ b/conan/api/conan_api.py
@@ -5,7 +5,7 @@ from conan.api.subapi.cache import CacheAPI
 from conan.api.subapi.command import CommandAPI
 from conan.api.subapi.local import LocalAPI
 from conan.api.subapi.lockfile import LockfileAPI
-from conans import __version__ as client_version
+from conan import conan_version
 from conan.api.subapi.config import ConfigAPI
 from conan.api.subapi.download import DownloadAPI
 from conan.api.subapi.export import ExportAPI
@@ -20,7 +20,6 @@ from conan.api.subapi.search import SearchAPI
 from conan.api.subapi.upload import UploadAPI
 from conans.client.migrations import ClientMigrator
 from conan.errors import ConanException
-from conans.model.version import Version
 from conan.internal.paths import get_conan_user_home
 from conans.model.version_range import validate_conan_version
 
@@ -37,7 +36,7 @@ class ConanAPI:
         self.home_folder = self.cache_folder  # Lets call it home, deprecate "cache"
 
         # Migration system
-        migrator = ClientMigrator(self.cache_folder, Version(client_version))
+        migrator = ClientMigrator(self.cache_folder, conan_version)
         migrator.migrate()
 
         self.command = CommandAPI(self)
diff --git a/conan/api/output.py b/conan/api/output.py
index d224498bd..a94e16cb5 100644
--- a/conan/api/output.py
+++ b/conan/api/output.py
@@ -4,6 +4,7 @@ import sys
 import time
 from threading import Lock
 
+import colorama
 from colorama import Fore, Style
 
 from conan.errors import ConanException
@@ -283,15 +284,15 @@ def cli_out_write(data, fg=None, bg=None, endline="\n", indentation=0):
     """
     Output to be used by formatters to dump information to stdout
     """
-
-    fg_ = fg or ''
-    bg_ = bg or ''
-    if (fg or bg) and _color_enabled(sys.stdout):
-        data = f"{' ' * indentation}{fg_}{bg_}{data}{Style.RESET_ALL}{endline}"
+    if (fg or bg) and _color_enabled(sys.stdout):  # need color
+        data = f"{' ' * indentation}{fg or ''}{bg or ''}{data}{Style.RESET_ALL}{endline}"
+        sys.stdout.write(data)
     else:
         data = f"{' ' * indentation}{data}{endline}"
-
-    sys.stdout.write(data)
+        # https://github.com/conan-io/conan/issues/17245 avoid colorama crash and overhead
+        colorama.deinit()
+        sys.stdout.write(data)
+        colorama.reinit()
 
 
 class TimedOutput:
diff --git a/conan/api/subapi/export.py b/conan/api/subapi/export.py
index 4eeb0201b..e6e62c4eb 100644
--- a/conan/api/subapi/export.py
+++ b/conan/api/subapi/export.py
@@ -1,7 +1,7 @@
 from conan.api.output import ConanOutput
 from conan.internal.conan_app import ConanApp
 from conan.internal.api.export import cmd_export
-from conans.client.conanfile.package import run_package_method
+from conan.internal.methods import run_package_method
 from conans.client.graph.graph import BINARY_BUILD, RECIPE_INCACHE
 from conans.model.package_ref import PkgReference
 from conans.util.files import mkdir
diff --git a/conan/api/subapi/local.py b/conan/api/subapi/local.py
index 7b252a6bd..1b4c1962a 100644
--- a/conan/api/subapi/local.py
+++ b/conan/api/subapi/local.py
@@ -3,10 +3,9 @@ import os
 from conan.cli import make_abs_path
 from conan.internal.conan_app import ConanApp
 from conan.internal.api.local.editable import EditablePackages
-from conans.client.conanfile.build import run_build_method
+from conan.internal.methods import run_build_method, run_source_method
 from conans.client.graph.graph import CONTEXT_HOST
 from conans.client.graph.profile_node_definer import initialize_conanfile_profile
-from conans.client.source import run_source_method
 from conan.internal.errors import conanfile_exception_formatter
 from conan.errors import ConanException
 from conans.model.recipe_ref import RecipeReference
diff --git a/conan/api/subapi/new.py b/conan/api/subapi/new.py
index ae26f9d13..b9732daea 100644
--- a/conan/api/subapi/new.py
+++ b/conan/api/subapi/new.py
@@ -5,7 +5,7 @@ from jinja2 import Template, StrictUndefined, UndefinedError, Environment, meta
 
 from conan.errors import ConanException
 from conans.util.files import load
-from conans import __version__
+from conan import __version__
 
 
 class NewAPI:
diff --git a/conan/cli/cli.py b/conan/cli/cli.py
index 68769f6e5..c30d9ac30 100644
--- a/conan/cli/cli.py
+++ b/conan/cli/cli.py
@@ -16,7 +16,7 @@ from conan.cli.command import ConanSubCommand
 from conan.cli.exit_codes import SUCCESS, ERROR_MIGRATION, ERROR_GENERAL, USER_CTRL_C, \
     ERROR_SIGTERM, USER_CTRL_BREAK, ERROR_INVALID_CONFIGURATION, ERROR_UNEXPECTED
 from conan.internal.cache.home_paths import HomePaths
-from conans import __version__ as client_version
+from conan import __version__
 from conan.errors import ConanException, ConanInvalidConfiguration, ConanMigrationError
 
 _CONAN_INTERNAL_CUSTOM_COMMANDS_PATH = "_CONAN_INTERNAL_CUSTOM_COMMANDS_PATH"
@@ -176,7 +176,7 @@ class Cli:
             command = self._commands[command_argument]
         except KeyError as exc:
             if command_argument in ["-v", "--version"]:
-                cli_out_write("Conan version %s" % client_version)
+                cli_out_write("Conan version %s" % __version__)
                 return
 
             if command_argument in ["-h", "--help"]:
diff --git a/conan/cli/formatters/graph/build_order_html.py b/conan/cli/formatters/graph/build_order_html.py
index 07d6af46e..4d4ac9357 100644
--- a/conan/cli/formatters/graph/build_order_html.py
+++ b/conan/cli/formatters/graph/build_order_html.py
@@ -260,9 +260,10 @@ build_order_html = r"""
 </html>
 """
 
+
 def _render_build_order(build_order, template):
-    from conans import __version__ as client_version
-    context = {'build_order': build_order, 'version': client_version, }
+    from conan import __version__
+    context = {'build_order': build_order, 'version': __version__}
     return template.render(context)
 
 
diff --git a/conan/cli/formatters/graph/graph.py b/conan/cli/formatters/graph/graph.py
index 7bec8ba65..6b174f603 100644
--- a/conan/cli/formatters/graph/graph.py
+++ b/conan/cli/formatters/graph/graph.py
@@ -104,10 +104,10 @@ class _Grapher(object):
 def _render_graph(graph, error, template, template_folder):
     deps_graph = graph.serialize()
     graph = _Grapher(graph)
-    from conans import __version__ as client_version
+    from conan import __version__
     template = Template(template, autoescape=select_autoescape(['html', 'xml']))
     return template.render(deps_graph=deps_graph, graph=graph, error=error,
-                           base_template_path=template_folder, version=client_version)
+                           base_template_path=template_folder, version=__version__)
 
 
 def format_graph_html(result):
diff --git a/conan/cli/formatters/list/list.py b/conan/cli/formatters/list/list.py
index 13c114f33..3ac51e250 100644
--- a/conan/cli/formatters/list/list.py
+++ b/conan/cli/formatters/list/list.py
@@ -6,7 +6,7 @@ from jinja2 import Template, select_autoescape
 from conan.api.output import cli_out_write
 from conan.cli.formatters.list.search_table_html import list_packages_html_template
 from conans.util.files import load
-from conans import __version__ as client_version
+from conan import __version__
 
 
 def list_packages_html(result):
@@ -18,5 +18,5 @@ def list_packages_html(result):
     template = load(user_template) if os.path.isfile(user_template) else list_packages_html_template
     template = Template(template, autoescape=select_autoescape(['html', 'xml']))
     content = template.render(results=json.dumps(results), base_template_path=template_folder,
-                              version=client_version, cli_args=cli_args)
+                              version=__version__, cli_args=cli_args)
     cli_out_write(content)
diff --git a/conan/cps/cps.py b/conan/cps/cps.py
index 621a387ce..9f47c9959 100644
--- a/conan/cps/cps.py
+++ b/conan/cps/cps.py
@@ -71,7 +71,7 @@ class CPSComponent:
         return comp
 
     @staticmethod
-    def from_cpp_info(cpp_info, pkg_type, libname=None):
+    def from_cpp_info(cpp_info, conanfile, libname=None):
         cps_comp = CPSComponent()
         if not libname:
             cps_comp.definitions = cpp_info.defines
@@ -85,7 +85,7 @@ class CPSComponent:
             cps_comp.type = CPSComponentType.INTERFACE
             return cps_comp
 
-        cpp_info.deduce_locations(pkg_type)
+        cpp_info.deduce_locations(conanfile)
         cps_comp.type = CPSComponentType.from_conan(cpp_info.type)
         cps_comp.location = cpp_info.location
         cps_comp.link_location = cpp_info.link_location
@@ -168,18 +168,18 @@ class CPS:
 
         if not dep.cpp_info.has_components:
             if dep.cpp_info.libs and len(dep.cpp_info.libs) > 1:
-                comp = CPSComponent.from_cpp_info(dep.cpp_info, dep.package_type)  # base
+                comp = CPSComponent.from_cpp_info(dep.cpp_info, dep)  # base
                 base_name = f"_{cps.name}"
                 cps.components[base_name] = comp
                 for lib in dep.cpp_info.libs:
-                    comp = CPSComponent.from_cpp_info(dep.cpp_info, dep.package_type, lib)
+                    comp = CPSComponent.from_cpp_info(dep.cpp_info, dep, lib)
                     comp.requires.insert(0, f":{base_name}")  # dep to the common one
                     cps.components[lib] = comp
                 cps.default_components = dep.cpp_info.libs
                 # FIXME: What if one lib is named equal to the package?
             else:
                 # single component, called same as library
-                component = CPSComponent.from_cpp_info(dep.cpp_info, dep.package_type)
+                component = CPSComponent.from_cpp_info(dep.cpp_info, dep)
                 if not component.requires and dep.dependencies:
                     for transitive_dep in dep.dependencies.host.items():
                         dep_name = transitive_dep[0].ref.name
@@ -191,7 +191,7 @@ class CPS:
         else:
             sorted_comps = dep.cpp_info.get_sorted_components()
             for comp_name, comp in sorted_comps.items():
-                component = CPSComponent.from_cpp_info(comp, dep.package_type)
+                component = CPSComponent.from_cpp_info(comp, dep)
                 cps.components[comp_name] = component
             # Now by default all are default_components
             cps.default_components = [comp_name for comp_name in sorted_comps]
diff --git a/conan/internal/__init__.py b/conan/internal/__init__.py
index 976bfcb41..b50650e7d 100644
--- a/conan/internal/__init__.py
+++ b/conan/internal/__init__.py
@@ -1,6 +1,9 @@
 from conan.errors import ConanException
 
 
+REVISIONS = "revisions"  # capability
+
+
 def check_duplicated_generator(generator, conanfile):
     if generator.__class__.__name__ in conanfile.generators:
         raise ConanException(f"{generator.__class__.__name__} is declared in the generators "
diff --git a/conan/internal/methods.py b/conan/internal/methods.py
new file mode 100644
index 000000000..c8405bf55
--- /dev/null
+++ b/conan/internal/methods.py
@@ -0,0 +1,159 @@
+import os
+
+from conan.api.output import ConanOutput
+from conan.errors import ConanException
+from conan.internal.errors import conanfile_exception_formatter, conanfile_remove_attr
+from conan.internal.paths import CONANINFO
+from conans.model.manifest import FileTreeManifest
+from conans.model.package_ref import PkgReference
+from conans.model.pkg_type import PackageType
+from conans.model.requires import BuildRequirements, TestRequirements, ToolRequirements
+from conans.util.files import mkdir, chdir, save
+
+
+def run_source_method(conanfile, hook_manager):
+    mkdir(conanfile.source_folder)
+    with chdir(conanfile.source_folder):
+        hook_manager.execute("pre_source", conanfile=conanfile)
+        if hasattr(conanfile, "source"):
+            conanfile.output.highlight("Calling source() in {}".format(conanfile.source_folder))
+            with conanfile_exception_formatter(conanfile, "source"):
+                with conanfile_remove_attr(conanfile, ['info', 'settings', "options"], "source"):
+                    conanfile.source()
+        hook_manager.execute("post_source", conanfile=conanfile)
+
+
+def run_build_method(conanfile, hook_manager):
+    mkdir(conanfile.build_folder)
+    mkdir(conanfile.package_metadata_folder)
+    with chdir(conanfile.build_folder):
+        hook_manager.execute("pre_build", conanfile=conanfile)
+        if hasattr(conanfile, "build"):
+            conanfile.output.highlight("Calling build()")
+            with conanfile_exception_formatter(conanfile, "build"):
+                try:
+                    conanfile.build()
+                except Exception:
+                    hook_manager.execute("post_build_fail", conanfile=conanfile)
+                    raise
+        hook_manager.execute("post_build", conanfile=conanfile)
+
+
+def run_package_method(conanfile, package_id, hook_manager, ref):
+    """ calls the recipe "package()" method
+    - Assigns folders to conanfile.package_folder, source_folder, install_folder, build_folder
+    - Calls pre-post package hook
+    """
+
+    if conanfile.package_folder == conanfile.build_folder:
+        raise ConanException("Cannot 'conan package' to the build folder. "
+                             "--build-folder and package folder can't be the same")
+
+    mkdir(conanfile.package_folder)
+    scoped_output = conanfile.output
+    # Make the copy of all the patterns
+    scoped_output.info("Generating the package")
+    scoped_output.info("Packaging in folder %s" % conanfile.package_folder)
+
+    hook_manager.execute("pre_package", conanfile=conanfile)
+    if hasattr(conanfile, "package"):
+        scoped_output.highlight("Calling package()")
+        with conanfile_exception_formatter(conanfile, "package"):
+            with chdir(conanfile.build_folder):
+                with conanfile_remove_attr(conanfile, ['info'], "package"):
+                    conanfile.package()
+    hook_manager.execute("post_package", conanfile=conanfile)
+
+    save(os.path.join(conanfile.package_folder, CONANINFO), conanfile.info.dumps())
+    manifest = FileTreeManifest.create(conanfile.package_folder)
+    manifest.save(conanfile.package_folder)
+    package_output = ConanOutput(scope="%s: package()" % scoped_output.scope)
+    manifest.report_summary(package_output, "Packaged")
+
+    prev = manifest.summary_hash
+    scoped_output.info("Created package revision %s" % prev)
+    pref = PkgReference(ref, package_id)
+    pref.revision = prev
+    scoped_output.success("Package '%s' created" % package_id)
+    scoped_output.success("Full package reference: {}".format(pref.repr_notime()))
+    return prev
+
+
+def run_configure_method(conanfile, down_options, profile_options, ref):
+    """ Run all the config-related functions for the given conanfile object """
+
+    initial_requires_count = len(conanfile.requires)
+
+    if hasattr(conanfile, "config_options"):
+        with conanfile_exception_formatter(conanfile, "config_options"):
+            conanfile.config_options()
+    elif "auto_shared_fpic" in conanfile.implements:
+        auto_shared_fpic_config_options(conanfile)
+
+    auto_language(conanfile)  # default implementation removes `compiler.cstd`
+
+    # Assign only the current package options values, but none of the dependencies
+    is_consumer = conanfile._conan_is_consumer
+    conanfile.options.apply_downstream(down_options, profile_options, ref, is_consumer)
+
+    if hasattr(conanfile, "configure"):
+        with conanfile_exception_formatter(conanfile, "configure"):
+            conanfile.configure()
+    elif "auto_shared_fpic" in conanfile.implements:
+        auto_shared_fpic_configure(conanfile)
+
+    if initial_requires_count != len(conanfile.requires):
+        conanfile.output.warning("Requirements should only be added in the requirements()/"
+                                 "build_requirements() methods, not configure()/config_options(), "
+                                 "which might raise errors in the future.", warn_tag="deprecated")
+
+    result = conanfile.options.get_upstream_options(down_options, ref, is_consumer)
+    self_options, up_options, private_up_options = result
+    # self_options are the minimum to reproduce state, as defined from downstream (not profile)
+    conanfile.self_options = self_options
+    # up_options are the minimal options that should be propagated to dependencies
+    conanfile.up_options = up_options
+    conanfile.private_up_options = private_up_options
+
+    PackageType.compute_package_type(conanfile)
+
+    conanfile.build_requires = BuildRequirements(conanfile.requires)
+    conanfile.test_requires = TestRequirements(conanfile.requires)
+    conanfile.tool_requires = ToolRequirements(conanfile.requires)
+
+    if hasattr(conanfile, "requirements"):
+        with conanfile_exception_formatter(conanfile, "requirements"):
+            conanfile.requirements()
+
+    if hasattr(conanfile, "build_requirements"):
+        with conanfile_exception_formatter(conanfile, "build_requirements"):
+            conanfile.build_requirements()
+
+
+def auto_shared_fpic_config_options(conanfile):
+    if conanfile.settings.get_safe("os") == "Windows":
+        conanfile.options.rm_safe("fPIC")
+
+
+def auto_shared_fpic_configure(conanfile):
+    if conanfile.options.get_safe("header_only"):
+        conanfile.options.rm_safe("fPIC")
+        conanfile.options.rm_safe("shared")
+    elif conanfile.options.get_safe("shared"):
+        conanfile.options.rm_safe("fPIC")
+
+
+def auto_header_only_package_id(conanfile):
+    if conanfile.options.get_safe("header_only") or conanfile.package_type is PackageType.HEADER:
+        conanfile.info.clear()
+
+
+def auto_language(conanfile):
+    if not conanfile.languages:
+        conanfile.settings.rm_safe("compiler.cstd")
+        return
+    if "C" not in conanfile.languages:
+        conanfile.settings.rm_safe("compiler.cstd")
+    if "C++" not in conanfile.languages:
+        conanfile.settings.rm_safe("compiler.cppstd")
+        conanfile.settings.rm_safe("compiler.libcxx")
diff --git a/conan/tools/cmake/cmakedeps2/cmakedeps.py b/conan/tools/cmake/cmakedeps2/cmakedeps.py
index b92e8276e..bdc6bba6f 100644
--- a/conan/tools/cmake/cmakedeps2/cmakedeps.py
+++ b/conan/tools/cmake/cmakedeps2/cmakedeps.py
@@ -4,6 +4,7 @@ import textwrap
 
 from jinja2 import Template
 
+from conan.api.output import Color
 from conan.internal import check_duplicated_generator
 from conan.tools.cmake.cmakedeps2.config import ConfigTemplate2
 from conan.tools.cmake.cmakedeps2.config_version import ConfigVersionTemplate2
@@ -50,6 +51,7 @@ class CMakeDeps2:
 
         # Iterate all the transitive requires
         ret = {}
+        direct_deps = []
         for require, dep in list(host_req.items()) + list(build_req.items()) + list(test_req.items()):
             cmake_find_mode = self.get_property("cmake_find_mode", dep)
             cmake_find_mode = cmake_find_mode or FIND_MODE_CONFIG
@@ -57,6 +59,8 @@ class CMakeDeps2:
             if cmake_find_mode == FIND_MODE_NONE:
                 continue
 
+            if require.direct:
+                direct_deps.append(dep)
             config = ConfigTemplate2(self, dep)
             ret[config.filename] = config.content()
             config_version = ConfigVersionTemplate2(self, dep)
@@ -66,8 +70,26 @@ class CMakeDeps2:
             ret[targets.filename] = targets.content()
             target_configuration = TargetConfigurationTemplate2(self, dep, require)
             ret[target_configuration.filename] = target_configuration.content()
+
+        self._print_help(direct_deps)
         return ret
 
+    def _print_help(self, direct_deps):
+        if direct_deps:
+            msg = ["CMakeDeps necessary find_package() and targets for your CMakeLists.txt"]
+            targets = []
+            for dep in direct_deps:
+                msg.append(f"    find_package({self.get_cmake_filename(dep)})")
+                if not dep.cpp_info.exe:
+                    target_name = self.get_property("cmake_target_name", dep)
+                    targets.append(target_name or f"{dep.ref.name}::{dep.ref.name}")
+            if targets:
+                msg.append(f"    target_link_libraries(... {' '.join(targets)})")
+            if self._conanfile._conan_is_consumer:
+                self._conanfile.output.info("\n".join(msg), fg=Color.CYAN)
+            else:
+                self._conanfile.output.verbose("\n".join(msg))
+
     def set_property(self, dep, prop, value, build_context=False):
         """
         Using this method you can overwrite the :ref:`property<CMakeDeps Properties>` values set by
diff --git a/conan/tools/cmake/cmakedeps2/target_configuration.py b/conan/tools/cmake/cmakedeps2/target_configuration.py
index 5d8c21504..e887a828a 100644
--- a/conan/tools/cmake/cmakedeps2/target_configuration.py
+++ b/conan/tools/cmake/cmakedeps2/target_configuration.py
@@ -39,7 +39,11 @@ class TargetConfigurationTemplate2:
         transitive_reqs = self._cmakedeps.get_transitive_requires(self._conanfile)
         if not requires and not components:  # global cpp_info without components definition
             # require the pkgname::pkgname base (user defined) or INTERFACE base target
-            return [f"{d.ref.name}::{d.ref.name}" for d in transitive_reqs.values()]
+            targets = []
+            for d in transitive_reqs.values():
+                dep_target = self._cmakedeps.get_property("cmake_target_name", d)
+                targets.append(dep_target or f"{d.ref.name}::{d.ref.name}")
+            return targets
 
         for required_pkg, required_comp in requires:
             if required_pkg is None:  # Points to a component of same package
@@ -192,6 +196,7 @@ class TargetConfigurationTemplate2:
         """
         root_target_name = self._cmakedeps.get_property("cmake_target_name", self._conanfile)
         root_target_name = root_target_name or f"{pkg_name}::{pkg_name}"
+        # TODO: What if an exe target is called like the pkg_name::pkg_name
         if libs and root_target_name not in libs:
             # Add a generic interface target for the package depending on the others
             if cpp_info.default_components is not None:
diff --git a/conan/tools/meson/toolchain.py b/conan/tools/meson/toolchain.py
index 743d38cbb..363861b8e 100644
--- a/conan/tools/meson/toolchain.py
+++ b/conan/tools/meson/toolchain.py
@@ -16,7 +16,7 @@ from conan.tools.microsoft import VCVars, msvc_runtime_flag
 from conans.util.files import save
 
 
-class MesonToolchain(object):
+class MesonToolchain:
     """
     MesonToolchain generator
     """
@@ -156,7 +156,7 @@ class MesonToolchain(object):
         self._conanfile = conanfile
         self._native = native
         self._is_apple_system = is_apple_os(self._conanfile)
-        is_cross_building = cross_building(conanfile, skip_x64_x86=True)
+        is_cross_building = cross_building(conanfile)  # x86_64->x86 is considered cross-building
         if not is_cross_building and native:
             raise ConanException("You can only pass native=True if you're cross-building, "
                                  "otherwise, it could cause unexpected results.")
@@ -164,8 +164,8 @@ class MesonToolchain(object):
         # Values are kept as Python built-ins so users can modify them more easily, and they are
         # only converted to Meson file syntax for rendering
         # priority: first user conf, then recipe, last one is default "ninja"
-        self._backend = conanfile.conf.get("tools.meson.mesontoolchain:backend",
-                                           default=backend or 'ninja')
+        self._backend = self._conanfile_conf.get("tools.meson.mesontoolchain:backend",
+                                                 default=backend or 'ninja')
         build_type = self._conanfile.settings.get_safe("build_type")
         self._buildtype = {"Debug": "debug",  # Note, it is not "'debug'"
                            "Release": "release",
@@ -424,13 +424,13 @@ class MesonToolchain(object):
         exelinkflags = self._conanfile_conf.get("tools.build:exelinkflags", default=[], check_type=list)
         linker_scripts = self._conanfile_conf.get("tools.build:linker_scripts", default=[], check_type=list)
         linker_script_flags = ['-T"' + linker_script + '"' for linker_script in linker_scripts]
-        defines = self._conanfile.conf.get("tools.build:defines", default=[], check_type=list)
+        defines = self._conanfile_conf.get("tools.build:defines", default=[], check_type=list)
         sys_root = [f"--sysroot={self._sys_root}"] if self._sys_root else [""]
+        ld = sharedlinkflags + exelinkflags + linker_script_flags + sys_root + self.extra_ldflags
         return {
             "cxxflags": cxxflags + sys_root + self.extra_cxxflags,
             "cflags": cflags + sys_root + self.extra_cflags,
-            "ldflags": sharedlinkflags + exelinkflags + linker_script_flags
-                       + sys_root + self.extra_ldflags,
+            "ldflags": ld,
             "defines": [f"-D{d}" for d in (defines + self.extra_defines)]
         }
 
@@ -447,11 +447,12 @@ class MesonToolchain(object):
     def _sanitize_env_format(value):
         if value is None or isinstance(value, list):
             return value
+        if not isinstance(value, str):
+            raise ConanException(f"MesonToolchain: Value '{value}' should be a string")
         ret = [x.strip() for x in value.split() if x]
         return ret[0] if len(ret) == 1 else ret
 
     def _context(self):
-
         apple_flags = self.apple_isysroot_flag + self.apple_arch_flag + self.apple_min_version_flag
         extra_flags = self._get_extra_flags()
 
@@ -474,10 +475,11 @@ class MesonToolchain(object):
 
         subproject_options = {}
         for subproject, listkeypair in self.subproject_options.items():
-            if listkeypair is not None and listkeypair is not []:
-                subproject_options[subproject] = []
-                for keypair in listkeypair:
-                    subproject_options[subproject].append({k: to_meson_value(v) for k, v in keypair.items()})
+            if listkeypair:
+                if not isinstance(listkeypair, list):
+                    raise ConanException("MesonToolchain.subproject_options must be a list of dicts")
+                subproject_options[subproject] = [{k: to_meson_value(v) for k, v in keypair.items()}
+                                                  for keypair in listkeypair]
 
         return {
             # https://mesonbuild.com/Machine-files.html#properties
@@ -555,6 +557,7 @@ class MesonToolchain(object):
         If Windows OS, it will be created a ``conanvcvars.bat`` as well.
         """
         check_duplicated_generator(self, self._conanfile)
+        self._conanfile.output.info(f"MesonToolchain generated: {self._filename}")
         save(self._filename, self._content)
         # FIXME: Should we check the OS and compiler to call VCVars?
         VCVars(self._conanfile).generate()
diff --git a/conan/tools/ros/rosenv.py b/conan/tools/ros/rosenv.py
index 5a6eb644b..fabe6866a 100644
--- a/conan/tools/ros/rosenv.py
+++ b/conan/tools/ros/rosenv.py
@@ -8,22 +8,27 @@ from conan.tools.files import save
 class ROSEnv:
     """
     Generator to serve as integration for Robot Operating System 2 development workspaces.
-    It generates a conanrosenv.sh file that when sources sets variables so the Conan
-    dependencies are found by CMake and the run environment is also set.
 
     IMPORTANT: This generator should be used together with CMakeDeps and CMakeToolchain generators.
     """
 
     def __init__(self, conanfile):
+        """
+        :param conanfile: ``< ConanFile object >`` The current recipe object. Always use ``self``.
+        """
         self._conanfile = conanfile
         self.variables = {}
         self._build_script_file = "conanrosenv-build.sh"
         self._wrapper_script_file = "conanrosenv.sh"
 
     def generate(self):
+        """
+        Creates a ``conanrosenv.sh`` with the environment variables that are needed to build and
+        execute ROS packages with Conan dependencies.
+        """
         cmake_toolchain_path = os.path.join(self._conanfile.generators_folder,
                                             "conan_toolchain.cmake")
-        self.variables["CMAKE_TOOLCHAIN_FILE"] = f"\"{cmake_toolchain_path}\""
+        self.variables["CMAKE_TOOLCHAIN_FILE"] = cmake_toolchain_path
         build_type = self._conanfile.settings.get_safe("build_type")
         if build_type:
             self.variables["CMAKE_BUILD_TYPE"] = build_type
diff --git a/conans/__init__.py b/conans/__init__.py
index cbe2f0d7f..e69de29bb 100644
--- a/conans/__init__.py
+++ b/conans/__init__.py
@@ -1,4 +0,0 @@
-CHECKSUM_DEPLOY = "checksum_deploy"  # Only when v2
-REVISIONS = "revisions"  # Only when enabled in config, not by default look at server_launcher.py
-
-__version__ = '2.10.0-dev'
diff --git a/conans/client/conanfile/__init__.py b/conans/client/conanfile/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/conans/client/conanfile/build.py b/conans/client/conanfile/build.py
deleted file mode 100644
index 743be2885..000000000
--- a/conans/client/conanfile/build.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from conan.internal.errors import conanfile_exception_formatter
-from conans.util.files import chdir, mkdir
-
-
-def run_build_method(conanfile, hook_manager):
-    mkdir(conanfile.build_folder)
-    mkdir(conanfile.package_metadata_folder)
-    with chdir(conanfile.build_folder):
-        hook_manager.execute("pre_build", conanfile=conanfile)
-        if hasattr(conanfile, "build"):
-            conanfile.output.highlight("Calling build()")
-            with conanfile_exception_formatter(conanfile, "build"):
-                try:
-                    conanfile.build()
-                except Exception:
-                    hook_manager.execute("post_build_fail", conanfile=conanfile)
-                    raise
-        hook_manager.execute("post_build", conanfile=conanfile)
diff --git a/conans/client/conanfile/configure.py b/conans/client/conanfile/configure.py
deleted file mode 100644
index bf99cb0e7..000000000
--- a/conans/client/conanfile/configure.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from conan.internal.errors import conanfile_exception_formatter
-from conans.model.pkg_type import PackageType
-from conans.model.requires import BuildRequirements, TestRequirements, ToolRequirements
-from conans.client.conanfile.implementations import auto_shared_fpic_config_options, \
-    auto_shared_fpic_configure, auto_language
-
-
-def run_configure_method(conanfile, down_options, profile_options, ref):
-    """ Run all the config-related functions for the given conanfile object """
-
-    initial_requires_count = len(conanfile.requires)
-
-    if hasattr(conanfile, "config_options"):
-        with conanfile_exception_formatter(conanfile, "config_options"):
-            conanfile.config_options()
-    elif "auto_shared_fpic" in conanfile.implements:
-        auto_shared_fpic_config_options(conanfile)
-
-    auto_language(conanfile)  # default implementation removes `compiler.cstd`
-
-    # Assign only the current package options values, but none of the dependencies
-    is_consumer = conanfile._conan_is_consumer
-    conanfile.options.apply_downstream(down_options, profile_options, ref, is_consumer)
-
-    if hasattr(conanfile, "configure"):
-        with conanfile_exception_formatter(conanfile, "configure"):
-            conanfile.configure()
-    elif "auto_shared_fpic" in conanfile.implements:
-        auto_shared_fpic_configure(conanfile)
-
-    if initial_requires_count != len(conanfile.requires):
-        conanfile.output.warning("Requirements should only be added in the requirements()/build_requirements() methods, not configure()/config_options(), which might raise errors in the future.", warn_tag="deprecated")
-
-    result = conanfile.options.get_upstream_options(down_options, ref, is_consumer)
-    self_options, up_options, private_up_options = result
-    # self_options are the minimum to reproduce state, as defined from downstream (not profile)
-    conanfile.self_options = self_options
-    # up_options are the minimal options that should be propagated to dependencies
-    conanfile.up_options = up_options
-    conanfile.private_up_options = private_up_options
-
-    PackageType.compute_package_type(conanfile)
-
-    conanfile.build_requires = BuildRequirements(conanfile.requires)
-    conanfile.test_requires = TestRequirements(conanfile.requires)
-    conanfile.tool_requires = ToolRequirements(conanfile.requires)
-
-    if hasattr(conanfile, "requirements"):
-        with conanfile_exception_formatter(conanfile, "requirements"):
-            conanfile.requirements()
-
-    if hasattr(conanfile, "build_requirements"):
-        with conanfile_exception_formatter(conanfile, "build_requirements"):
-            conanfile.build_requirements()
diff --git a/conans/client/conanfile/implementations.py b/conans/client/conanfile/implementations.py
deleted file mode 100644
index 14cabc760..000000000
--- a/conans/client/conanfile/implementations.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from conans.model.pkg_type import PackageType
-
-
-def auto_shared_fpic_config_options(conanfile):
-    if conanfile.settings.get_safe("os") == "Windows":
-        conanfile.options.rm_safe("fPIC")
-
-
-def auto_shared_fpic_configure(conanfile):
-    if conanfile.options.get_safe("header_only"):
-        conanfile.options.rm_safe("fPIC")
-        conanfile.options.rm_safe("shared")
-    elif conanfile.options.get_safe("shared"):
-        conanfile.options.rm_safe("fPIC")
-
-
-def auto_header_only_package_id(conanfile):
-    if conanfile.options.get_safe("header_only") or conanfile.package_type is PackageType.HEADER:
-        conanfile.info.clear()
-
-
-def auto_language(conanfile):
-    if not conanfile.languages:
-        conanfile.settings.rm_safe("compiler.cstd")
-        return
-    if "C" not in conanfile.languages:
-        conanfile.settings.rm_safe("compiler.cstd")
-    if "C++" not in conanfile.languages:
-        conanfile.settings.rm_safe("compiler.cppstd")
-        conanfile.settings.rm_safe("compiler.libcxx")
diff --git a/conans/client/conanfile/package.py b/conans/client/conanfile/package.py
deleted file mode 100644
index dd90d3138..000000000
--- a/conans/client/conanfile/package.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import os
-
-from conan.api.output import ConanOutput
-from conan.internal.errors import conanfile_remove_attr, conanfile_exception_formatter
-from conan.errors import ConanException
-from conans.model.manifest import FileTreeManifest
-from conans.model.package_ref import PkgReference
-from conan.internal.paths import CONANINFO
-from conans.util.files import save, mkdir, chdir
-
-
-def run_package_method(conanfile, package_id, hook_manager, ref):
-    """ calls the recipe "package()" method
-    - Assigns folders to conanfile.package_folder, source_folder, install_folder, build_folder
-    - Calls pre-post package hook
-    """
-
-    if conanfile.package_folder == conanfile.build_folder:
-        raise ConanException("Cannot 'conan package' to the build folder. "
-                             "--build-folder and package folder can't be the same")
-
-    mkdir(conanfile.package_folder)
-    scoped_output = conanfile.output
-    # Make the copy of all the patterns
-    scoped_output.info("Generating the package")
-    scoped_output.info("Packaging in folder %s" % conanfile.package_folder)
-
-    hook_manager.execute("pre_package", conanfile=conanfile)
-    if hasattr(conanfile, "package"):
-        scoped_output.highlight("Calling package()")
-        with conanfile_exception_formatter(conanfile, "package"):
-            with chdir(conanfile.build_folder):
-                with conanfile_remove_attr(conanfile, ['info'], "package"):
-                    conanfile.package()
-    hook_manager.execute("post_package", conanfile=conanfile)
-
-    save(os.path.join(conanfile.package_folder, CONANINFO), conanfile.info.dumps())
-    manifest = FileTreeManifest.create(conanfile.package_folder)
-    manifest.save(conanfile.package_folder)
-    package_output = ConanOutput(scope="%s: package()" % scoped_output.scope)
-    manifest.report_summary(package_output, "Packaged")
-
-    prev = manifest.summary_hash
-    scoped_output.info("Created package revision %s" % prev)
-    pref = PkgReference(ref, package_id)
-    pref.revision = prev
-    scoped_output.success("Package '%s' created" % package_id)
-    scoped_output.success("Full package reference: {}".format(pref.repr_notime()))
-    return prev
-
-
diff --git a/conans/client/graph/compute_pid.py b/conans/client/graph/compute_pid.py
index 9aa690bb9..5852b9387 100644
--- a/conans/client/graph/compute_pid.py
+++ b/conans/client/graph/compute_pid.py
@@ -2,8 +2,8 @@ from collections import OrderedDict
 
 from conan.internal.errors import conanfile_remove_attr, conanfile_exception_formatter
 from conan.errors import ConanException, ConanInvalidConfiguration
+from conan.internal.methods import auto_header_only_package_id
 from conans.model.info import ConanInfo, RequirementsInfo, RequirementInfo, PythonRequiresInfo
-from conans.client.conanfile.implementations import auto_header_only_package_id
 
 
 def compute_package_id(node, modes, config_version):
diff --git a/conans/client/graph/graph_builder.py b/conans/client/graph/graph_builder.py
index 7a5999fea..8745f8f07 100644
--- a/conans/client/graph/graph_builder.py
+++ b/conans/client/graph/graph_builder.py
@@ -3,7 +3,7 @@ import copy
 from collections import deque
 
 from conan.internal.cache.conan_reference_layout import BasicLayout
-from conans.client.conanfile.configure import run_configure_method
+from conan.internal.methods import run_configure_method
 from conans.client.graph.graph import DepsGraph, Node, CONTEXT_HOST, \
     CONTEXT_BUILD, TransitiveRequirement, RECIPE_VIRTUAL, RECIPE_EDITABLE
 from conans.client.graph.graph import RECIPE_PLATFORM
diff --git a/conans/client/installer.py b/conans/client/installer.py
index bdeb24efe..b9bb03d7f 100644
--- a/conans/client/installer.py
+++ b/conans/client/installer.py
@@ -3,8 +3,7 @@ import shutil
 from multiprocessing.pool import ThreadPool
 
 from conan.api.output import ConanOutput
-from conans.client.conanfile.build import run_build_method
-from conans.client.conanfile.package import run_package_method
+from conan.internal.methods import run_build_method, run_package_method
 from conan.internal.api.install.generators import write_generators
 from conans.client.graph.graph import BINARY_BUILD, BINARY_CACHE, BINARY_DOWNLOAD, BINARY_EDITABLE, \
     BINARY_UPDATE, BINARY_EDITABLE_BUILD, BINARY_SKIP
diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py
index 7b7762c7c..edb2ce989 100644
--- a/conans/client/rest/conan_requester.py
+++ b/conans/client/rest/conan_requester.py
@@ -11,7 +11,7 @@ from requests.adapters import HTTPAdapter
 
 from conan.internal.cache.home_paths import HomePaths
 
-from conans import __version__ as client_version
+from conan import __version__
 from conans.client.loader import load_python_file
 from conan.internal.errors import scoped_traceback
 from conan.errors import ConanException
@@ -121,7 +121,7 @@ class ConanRequester:
         platform_info = "; ".join([" ".join([platform.system(), platform.release()]),
                                    "Python " + platform.python_version(),
                                    platform.machine()])
-        self._user_agent = "Conan/%s (%s)" % (client_version, platform_info)
+        self._user_agent = "Conan/%s (%s)" % (__version__, platform_info)
 
     @staticmethod
     def _get_retries(config):
diff --git a/conans/client/rest/rest_client.py b/conans/client/rest/rest_client.py
index 27099a3f0..b35d1b16f 100644
--- a/conans/client/rest/rest_client.py
+++ b/conans/client/rest/rest_client.py
@@ -1,7 +1,9 @@
-from conans import CHECKSUM_DEPLOY, REVISIONS
+from conan.internal import REVISIONS
 from conans.client.rest.rest_client_v2 import RestV2Methods
 from conan.errors import ConanException
 
+CHECKSUM_DEPLOY = "checksum_deploy"  # capability
+
 
 class RestApiClient:
     """
diff --git a/conans/client/source.py b/conans/client/source.py
index 9b0aee5b0..053de6bdb 100644
--- a/conans/client/source.py
+++ b/conans/client/source.py
@@ -1,11 +1,12 @@
 import os
 
 from conan.api.output import ConanOutput
+from conan.internal.methods import run_source_method
 from conan.tools.env import VirtualBuildEnv
-from conan.internal.errors import conanfile_remove_attr, conanfile_exception_formatter, NotFoundException
+from conan.internal.errors import NotFoundException
 from conan.errors import ConanException
 from conans.util.files import (is_dirty, mkdir, rmdir, set_dirty_context_manager,
-                               merge_directories, clean_dirty, chdir)
+                               merge_directories, clean_dirty)
 
 
 def _try_get_sources(ref, remote_manager, recipe_layout, remote):
@@ -73,15 +74,3 @@ def config_source(export_source_folder, conanfile, hook_manager):
                     run_source_method(conanfile, hook_manager)
             else:
                 run_source_method(conanfile, hook_manager)
-
-
-def run_source_method(conanfile, hook_manager):
-    mkdir(conanfile.source_folder)
-    with chdir(conanfile.source_folder):
-        hook_manager.execute("pre_source", conanfile=conanfile)
-        if hasattr(conanfile, "source"):
-            conanfile.output.highlight("Calling source() in {}".format(conanfile.source_folder))
-            with conanfile_exception_formatter(conanfile, "source"):
-                with conanfile_remove_attr(conanfile, ['info', 'settings', "options"], "source"):
-                    conanfile.source()
-        hook_manager.execute("post_source", conanfile=conanfile)
diff --git a/conans/model/build_info.py b/conans/model/build_info.py
index 4b4ef9f33..ca4d00e36 100644
--- a/conans/model/build_info.py
+++ b/conans/model/build_info.py
@@ -481,7 +481,8 @@ class _Component:
     def parsed_requires(self):
         return [r.split("::", 1) if "::" in r else (None, r) for r in self.requires]
 
-    def deduce_locations(self, pkg_type):
+    def deduce_locations(self, conanfile):
+        pkg_type = conanfile.package_type
         if self._exe:   # exe is a new field, it should have the correct location
             return
         if self._location or self._link_location:
@@ -519,10 +520,11 @@ class _Component:
         static_location = _find_matching(static_patterns, libdirs)
         shared_location = _find_matching(shared_patterns, libdirs)
         dll_location = _find_matching(dll_patterns, bindirs)
+        out = ConanOutput(scope=str(conanfile))
         if static_location:
             if shared_location:
-                ConanOutput().warning(f"Lib {libname} has both static {static_location} and "
-                                      f"shared {shared_location} in the same package")
+                out.warning(f"Lib {libname} has both static {static_location} and "
+                            f"shared {shared_location} in the same package")
                 if pkg_type is PackageType.STATIC:
                     self._location = static_location
                     self._type = PackageType.STATIC
@@ -543,9 +545,13 @@ class _Component:
             # Only .dll but no link library
             self._location = dll_location
             self._type = PackageType.SHARED
+        if not self._location:
+            raise ConanException(f"{conanfile}: Cannot obtain 'location' for library '{libname}' "
+                                 f"in {libdirs}. You can specify 'cpp_info.location' directly "
+                                 f"or report in github.com/conan-io/conan/issues if you think it "
+                                 f"should have been deduced correctly.")
         if self._type != pkg_type:
-            ConanOutput().warning(f"Lib {libname} deduced as '{self._type}, "
-                                  f"but 'package_type={pkg_type}'")
+            out.warning(f"Lib {libname} deduced as '{self._type}, but 'package_type={pkg_type}'")
 
 
 class CppInfo:
@@ -717,8 +723,6 @@ class CppInfo:
         return ret
 
     def deduce_full_cpp_info(self, conanfile):
-        pkg_type = conanfile.package_type
-
         result = CppInfo()  # clone it
 
         if self.libs and len(self.libs) > 1:  # expand in multiple components
@@ -744,8 +748,8 @@ class CppInfo:
             result.default_components = self.default_components
             result.components = {k: v.clone() for k, v in self.components.items()}
 
-        result._package.deduce_locations(pkg_type)
+        result._package.deduce_locations(conanfile)
         for comp in result.components.values():
-            comp.deduce_locations(pkg_type)
+            comp.deduce_locations(conanfile)
 
         return result
diff --git a/conans/model/version_range.py b/conans/model/version_range.py
index ee4e5906c..841abb3d1 100644
--- a/conans/model/version_range.py
+++ b/conans/model/version_range.py
@@ -1,9 +1,8 @@
 from functools import total_ordering
 from typing import Optional
 
+from conans.model.version import Version
 from conan.errors import ConanException
-from conans.model.recipe_ref import Version
-from conans import __version__ as client_version
 
 
 @total_ordering
@@ -229,7 +228,8 @@ class VersionRange:
 
 
 def validate_conan_version(required_range):
-    clientver = Version(client_version)
+    from conan import __version__  # To avoid circular imports
+    clientver = Version(__version__)
     version_range = VersionRange(required_range)
     for conditions in version_range.condition_sets:
         conditions.prerelease = True
diff --git a/conans/server/__init__.py b/conans/server/__init__.py
index ca82a4930..6e493f6cb 100644
--- a/conans/server/__init__.py
+++ b/conans/server/__init__.py
@@ -1,4 +1,4 @@
-from conans import REVISIONS
+from conan.internal import REVISIONS
 
 COMPLEX_SEARCH_CAPABILITY = "complex_search"
 
diff --git a/conans/server/launcher.py b/conans/server/launcher.py
index 12ddb2a60..7f1f9fd43 100644
--- a/conans/server/launcher.py
+++ b/conans/server/launcher.py
@@ -2,7 +2,7 @@
 import os
 import sys
 
-from conans import REVISIONS
+from conan.internal import REVISIONS
 from conans.server import SERVER_CAPABILITIES
 from conans.server.conf import get_server_store
 
diff --git a/conans/server/migrate.py b/conans/server/migrate.py
index ed6a230db..3e79efedd 100644
--- a/conans/server/migrate.py
+++ b/conans/server/migrate.py
@@ -1,5 +1,4 @@
-from conans import __version__ as SERVER_VERSION
-from conans.model.version import Version
+from conan import conan_version
 from conans.server.conf import ConanServerConfigParser
 from conans.server.migrations import ServerMigrator
 
@@ -8,7 +7,7 @@ def migrate_and_get_server_config(base_folder, force_migration=False, is_custom_
     server_config = ConanServerConfigParser(base_folder, is_custom_path=is_custom_path)
     storage_path = server_config.disk_storage_path
     migrator = ServerMigrator(server_config.conan_folder, storage_path,
-                              Version(SERVER_VERSION), force_migration)
+                              conan_version, force_migration)
     migrator.migrate()
 
     # Init again server_config, migrator could change something
diff --git a/pyinstaller.py b/pyinstaller.py
index a4d6f22cb..75323736c 100644
--- a/pyinstaller.py
+++ b/pyinstaller.py
@@ -21,7 +21,7 @@ import platform
 import shutil
 import sys
 
-from conans import __version__
+from conan import __version__
 
 
 def _run_bin(pyinstaller_path):
diff --git a/setup.py b/setup.py
index 3c14b1b87..d2d685a7d 100644
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ def get_requires(filename):
 def load_version():
     """ Loads a file content """
     filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
-                                            "conans", "__init__.py"))
+                                            "conan", "__init__.py"))
     with open(filename, "rt") as version_file:
         conan_init = version_file.read()
         version = re.search(r"__version__ = '([0-9a-z.-]+)'", conan_init).group(1)
diff --git a/setup_server.py b/setup_server.py
index 821bdb07c..4da637264 100644
--- a/setup_server.py
+++ b/setup_server.py
@@ -32,7 +32,7 @@ def get_requires(filename):
 def load_version():
     """ Loads a file content """
     filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
-                                            "conans", "__init__.py"))
+                                            "conan", "__init__.py"))
     with open(filename, "rt") as version_file:
         conan_init = version_file.read()
         version = re.search(r"__version__ = '([0-9a-z.-]+)'", conan_init).group(1)


Test patch:
diff --git a/conan/test/utils/server_launcher.py b/conan/test/utils/server_launcher.py
index bc062432f..93c085293 100644
--- a/conan/test/utils/server_launcher.py
+++ b/conan/test/utils/server_launcher.py
@@ -3,7 +3,7 @@ import os
 import shutil
 import time
 
-from conans import REVISIONS
+from conan.internal import REVISIONS
 from conans.server import SERVER_CAPABILITIES
 from conans.server.conf import get_server_store
 from conans.server.crypto.jwt.jwt_credentials_manager import JWTCredentialsManager
diff --git a/conan/test/utils/tools.py b/conan/test/utils/tools.py
index 090a36c77..a84187934 100644
--- a/conan/test/utils/tools.py
+++ b/conan/test/utils/tools.py
@@ -27,7 +27,7 @@ from webtest.app import TestApp
 from conan.cli.exit_codes import SUCCESS, ERROR_GENERAL
 from conan.internal.cache.cache import PackageLayout, RecipeLayout, PkgCache
 from conan.internal.cache.home_paths import HomePaths
-from conans import REVISIONS
+from conan.internal import REVISIONS
 from conan.api.conan_api import ConanAPI
 from conan.api.model import Remote
 from conan.cli.cli import Cli, _CONAN_INTERNAL_CUSTOM_COMMANDS_PATH
diff --git a/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_new.py b/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_new.py
index e2c3a84be..b4c7d0926 100644
--- a/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_new.py
+++ b/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_new.py
@@ -91,6 +91,8 @@ class TestExes:
         c.save({"conanfile.py": consumer,
                 "CMakeLists.txt": cmake}, clean_first=True)
         c.run(f"build . -c tools.cmake.cmakedeps:new={new_value}")
+        assert "find_package(mytool)" in c.out
+        assert "target_link_libraries(..." not in c.out
         assert "Conan: Target declared imported executable 'MyTool::myexe'" in c.out
         assert "Mytool generating out.c!!!!!" in c.out
 
@@ -197,6 +199,8 @@ class TestLibs:
         c = matrix_client
         c.run("new cmake_lib -d name=app -d version=0.1 -d requires=matrix/1.0")
         c.run(f"build . -c tools.cmake.cmakedeps:new={new_value}")
+        assert "find_package(matrix)" in c.out
+        assert "target_link_libraries(... matrix::matrix)" in c.out
         assert "Conan: Target declared imported STATIC library 'matrix::matrix'" in c.out
 
     @pytest.mark.parametrize("shared", [False, True])
@@ -205,6 +209,8 @@ class TestLibs:
         c.run("new cmake_lib -d name=app -d version=0.1 -d requires=engine/1.0")
         shared = "-o engine/*:shared=True" if shared else ""
         c.run(f"build . {shared} -c tools.cmake.cmakedeps:new={new_value}")
+        assert "find_package(engine)" in c.out
+        assert "target_link_libraries(... engine::engine)" in c.out
         if shared:
             assert "matrix::matrix" not in c.out  # It is hidden as static behind the engine
             assert "Conan: Target declared imported SHARED library 'engine::engine'" in c.out
@@ -249,6 +255,58 @@ class TestLibs:
         assert "game/0.1: Hello World Release!"
 
 
+class TestLibsIntegration:
+    def test_libs_no_location(self):
+        # Integration test
+        # https://github.com/conan-io/conan/issues/17256
+        c = TestClient()
+        dep = textwrap.dedent("""
+            from conan import ConanFile
+            class Dep(ConanFile):
+                name = "dep"
+                version = "0.1"
+                settings = "build_type"
+                def package_info(self):
+                    self.cpp_info.libs = ["dep"]
+            """)
+
+        c.save({"dep/conanfile.py": dep,
+                "app/conanfile.py": GenConanfile().with_requires("dep/0.1")
+                                                  .with_settings("build_type")})
+
+        c.run("create dep")
+        c.run(f"install app -c tools.cmake.cmakedeps:new={new_value} -g CMakeDeps",
+              assert_error=True)
+        assert "ERROR: Error in generator 'CMakeDeps': dep/0.1: Cannot obtain 'location' " \
+               "for library 'dep'" in c.out
+
+    def test_custom_file_targetname(self):
+        # Integration test
+        c = TestClient()
+        dep = textwrap.dedent("""
+            from conan import ConanFile
+            class Dep(ConanFile):
+                name = "dep"
+                version = "0.1"
+                settings = "build_type"
+                def package_info(self):
+                    self.cpp_info.set_property("cmake_file_name", "MyDep")
+                    self.cpp_info.set_property("cmake_target_name", "MyTargetDep")
+                """)
+
+        c.save({"dep/conanfile.py": dep,
+                "pkg/conanfile.py": GenConanfile("pkg", "0.1").with_requires("dep/0.1"),
+                "app/conanfile.py": GenConanfile().with_requires("pkg/0.1")
+               .with_settings("build_type")})
+
+        c.run("create dep")
+        c.run("create pkg")
+        c.run(f"install app -c tools.cmake.cmakedeps:new={new_value} -g CMakeDeps")
+        targets_cmake = c.load("app/pkg-Targets-release.cmake")
+        assert "find_dependency(MyDep REQUIRED CONFIG)" in targets_cmake
+        assert "target_link_libraries(pkg::pkg INTERFACE MyTargetDep)" in targets_cmake
+
+
 class TestLibsLinkageTraits:
     def test_linkage_shared_static(self):
         """
@@ -299,6 +357,8 @@ class TestLibsComponents:
         c.save({"CMakeLists.txt": cmake,
                 "src/app.cpp": app_cpp})
         c.run(f"build . -c tools.cmake.cmakedeps:new={new_value}")
+        assert "find_package(matrix)" in c.out
+        assert "target_link_libraries(... matrix::matrix)" in c.out
         assert "Conan: Target declared imported STATIC library 'matrix::vector'" in c.out
         assert "Conan: Target declared imported STATIC library 'matrix::module'" in c.out
         if platform.system() == "Windows":
@@ -417,6 +477,7 @@ class TestLibsComponents:
                   cmake.install()
 
               def package_info(self):
+                  self.cpp_info.set_property("cmake_file_name", "MyEngine")
                   self.cpp_info.components["bots"].libs = ["bots"]
                   self.cpp_info.components["bots"].includedirs = ["include"]
                   self.cpp_info.components["bots"].libdirs = ["lib"]
@@ -470,7 +531,7 @@ class TestLibsComponents:
             cmake_minimum_required(VERSION 3.15)
             project(app CXX)
 
-            find_package(engine CONFIG REQUIRED)
+            find_package(MyEngine CONFIG REQUIRED)
 
             add_executable(app src/app.cpp)
             target_link_libraries(app PRIVATE engine::bots)
@@ -484,6 +545,7 @@ class TestLibsComponents:
         c.save({"CMakeLists.txt": cmake,
                 "src/app.cpp": app_cpp})
         c.run(f"create . -c tools.cmake.cmakedeps:new={new_value}")
+        assert "find_package(MyEngine)" in c.out
         assert "Conan: Target declared imported STATIC library 'matrix::vector'" in c.out
         assert "Conan: Target declared imported STATIC library 'matrix::module'" in c.out
         assert "Conan: Target declared imported INTERFACE library 'matrix::matrix'" in c.out
diff --git a/test/integration/command/help_test.py b/test/integration/command/help_test.py
index 0e5665da9..6003a8cda 100644
--- a/test/integration/command/help_test.py
+++ b/test/integration/command/help_test.py
@@ -1,4 +1,4 @@
-from conans import __version__
+from conan import __version__
 from conan.test.utils.tools import TestClient
 
 
diff --git a/test/integration/command/new_test.py b/test/integration/command/new_test.py
index 4700ede4e..0dbb71dea 100644
--- a/test/integration/command/new_test.py
+++ b/test/integration/command/new_test.py
@@ -3,7 +3,7 @@ import textwrap
 
 import pytest
 
-from conans import __version__ as client_version
+from conan import __version__
 from conan.test.utils.test_files import temp_folder
 from conan.test.utils.tools import TestClient
 from conans.util.files import save
@@ -79,7 +79,7 @@ class TestNewCommandUserTemplate:
         conanfile = client.load("conanfile.py")
         assert 'name = "hello"' in conanfile
         assert 'version = "0.1"' in conanfile
-        assert 'conan_version = "{}"'.format(client_version) in conanfile
+        assert 'conan_version = "{}"'.format(__version__) in conanfile
 
     def test_user_template_abs(self):
         tmp_folder = temp_folder()
diff --git a/test/integration/conanfile/required_conan_version_test.py b/test/integration/conanfile/required_conan_version_test.py
index 3bde82da8..cc63cc089 100644
--- a/test/integration/conanfile/required_conan_version_test.py
+++ b/test/integration/conanfile/required_conan_version_test.py
@@ -2,7 +2,7 @@ import textwrap
 
 import mock
 
-from conans import __version__
+from conan import __version__
 from conan.test.utils.tools import TestClient
 
 
@@ -22,10 +22,10 @@ def test_required_conan_version():
     client.run("source . ", assert_error=True)
     assert f"Current Conan version ({__version__}) does not satisfy the defined one (>=100.0)" in client.out
 
-    with mock.patch("conans.model.version_range.client_version", "101.0"):
+    with mock.patch("conan.__version__", "101.0"):
         client.run("export . --name=pkg --version=1.0")
 
-    with mock.patch("conans.model.version_range.client_version", "101.0-dev"):
+    with mock.patch("conan.__version__", "101.0-dev"):
         client.run("export . --name=pkg --version=1.0")
 
     client.run("install --requires=pkg/1.0@", assert_error=True)
diff --git a/test/integration/configuration/conf/test_conf.py b/test/integration/configuration/conf/test_conf.py
index 52e2bf858..dc0a24520 100644
--- a/test/integration/configuration/conf/test_conf.py
+++ b/test/integration/configuration/conf/test_conf.py
@@ -134,7 +134,7 @@ def test_new_config_file(client):
     assert "[conf] Either 'cache:read_only' does not exist in configuration list" in client.out
 
 
-@patch("conans.model.version_range.client_version", "1.26.0")
+@patch("conan.__version__", "1.26.0")
 def test_new_config_file_required_version():
     client = TestClient()
     conf = textwrap.dedent("""\
diff --git a/test/integration/configuration/requester_test.py b/test/integration/configuration/requester_test.py
index fe41b5bef..5acb47360 100644
--- a/test/integration/configuration/requester_test.py
+++ b/test/integration/configuration/requester_test.py
@@ -4,7 +4,7 @@ import unittest
 import mock
 from mock import Mock, MagicMock
 
-from conans import __version__
+from conan import __version__
 from conans.client.rest.conan_requester import ConanRequester
 from conans.model.conf import ConfDefinition
 from conan.test.utils.tools import temp_folder
diff --git a/test/integration/configuration/required_version_test.py b/test/integration/configuration/required_version_test.py
index 58714e856..8a352ce06 100644
--- a/test/integration/configuration/required_version_test.py
+++ b/test/integration/configuration/required_version_test.py
@@ -2,7 +2,7 @@ import os
 import unittest
 import mock
 
-from conans import __version__
+from conan import __version__
 from conan.errors import ConanException
 from conan.test.utils.test_files import temp_folder
 from conan.test.utils.tools import TestClient
@@ -11,7 +11,7 @@ from conans.util.files import save
 
 class RequiredVersionTest(unittest.TestCase):
 
-    @mock.patch("conans.model.version_range.client_version", "1.26.0")
+    @mock.patch("conan.__version__", "1.26.0")
     def test_wrong_version(self):
         required_version = "1.23.0"
         client = TestClient()
@@ -20,21 +20,21 @@ class RequiredVersionTest(unittest.TestCase):
         self.assertIn("Current Conan version (1.26.0) does not satisfy the defined "
                       "one ({})".format(required_version), client.out)
 
-    @mock.patch("conans.model.version_range.client_version", "1.22.0")
+    @mock.patch("conan.__version__", "1.22.0")
     def test_exact_version(self):
         required_version = "1.22.0"
         client = TestClient()
         client.save_home({"global.conf": f"core:required_conan_version={required_version}"})
         client.run("--help")
 
-    @mock.patch("conans.model.version_range.client_version", "2.1.0")
+    @mock.patch("conan.__version__", "2.1.0")
     def test_lesser_version(self):
         required_version = "<3.0"
         client = TestClient()
         client.save_home({"global.conf": f"core:required_conan_version={required_version}"})
         client.run("--help")
 
-    @mock.patch("conans.model.version_range.client_version", "1.0.0")
+    @mock.patch("conan.__version__", "1.0.0")
     def test_greater_version(self):
         required_version = ">0.1.0"
         client = TestClient()
diff --git a/test/integration/remote/server_error_test.py b/test/integration/remote/server_error_test.py
index d9868b273..ff0f72127 100644
--- a/test/integration/remote/server_error_test.py
+++ b/test/integration/remote/server_error_test.py
@@ -1,6 +1,6 @@
 import unittest
 
-from conans import REVISIONS
+from conan.internal import REVISIONS
 from conan.test.utils.tools import TestClient, TestServer, TestRequester
 from collections import namedtuple
 
diff --git a/test/integration/toolchains/meson/test_mesontoolchain.py b/test/integration/toolchains/meson/test_mesontoolchain.py
index d9ca23ea9..a9075c667 100644
--- a/test/integration/toolchains/meson/test_mesontoolchain.py
+++ b/test/integration/toolchains/meson/test_mesontoolchain.py
@@ -7,7 +7,6 @@ import pytest
 
 from conan.test.assets.genconanfile import GenConanfile
 from conan.test.utils.tools import TestClient
-from conan.tools.files import load
 from conan.tools.meson import MesonToolchain
 
 
@@ -540,8 +539,8 @@ def test_native_attribute():
                  "build": build,
                  "conanfile.py": conanfile})
     client.run("install . -pr:h host -pr:b build")
-    native_content = load(None, os.path.join(client.current_folder, MesonToolchain.native_filename))
-    cross_content = load(None, os.path.join(client.current_folder, MesonToolchain.cross_filename))
+    native_content = client.load(MesonToolchain.native_filename)
+    cross_content = client.load(MesonToolchain.cross_filename)
     expected_native = textwrap.dedent("""
     [binaries]
     c = 'clang'
@@ -640,9 +639,23 @@ def test_meson_sysroot_app():
                  "host": profile})
     client.run("install . -pr:h host -pr:b build")
     # Check the meson configuration file
-    conan_meson = client.load(os.path.join(client.current_folder, "conan_meson_cross.ini"))
+    conan_meson = client.load("conan_meson_cross.ini")
     assert f"sys_root = '{sysroot}'\n" in conan_meson
     assert re.search(r"c_args =.+--sysroot={}.+".format(sysroot), conan_meson)
     assert re.search(r"c_link_args =.+--sysroot={}.+".format(sysroot), conan_meson)
     assert re.search(r"cpp_args =.+--sysroot={}.+".format(sysroot), conan_meson)
     assert re.search(r"cpp_link_args =.+--sysroot={}.+".format(sysroot), conan_meson)
+
+
+def test_cross_x86_64_to_x86():
+    """
+    https://github.com/conan-io/conan/issues/17261
+    """
+
+    c = TestClient()
+    c.save({"conanfile.py": GenConanfile().with_settings("os", "compiler", "arch", "build_type")})
+    c.run("install . -g MesonToolchain -s arch=x86 -s:b arch=x86_64")
+    assert not os.path.exists(os.path.join(c.current_folder, MesonToolchain.native_filename))
+    cross = c.load(MesonToolchain.cross_filename)
+    assert "cpu = 'x86_64'" in cross  # This is the build machine
+    assert "cpu = 'x86'" in cross  # This is the host machine
diff --git a/test/integration/tools/conan_version_test.py b/test/integration/tools/conan_version_test.py
index 740f37139..32a6931f5 100644
--- a/test/integration/tools/conan_version_test.py
+++ b/test/integration/tools/conan_version_test.py
@@ -1,7 +1,7 @@
 import textwrap
 
 from conan.test.utils.tools import TestClient
-from conans import __version__
+from conan import __version__
 
 
 def test_conan_version():
@@ -10,7 +10,7 @@ def test_conan_version():
         from conan import ConanFile
         from conan import conan_version
         from conan.tools.scm import Version
-        from conans import __version__
+        from conan import __version__
 
         class pkg(ConanFile):
 
diff --git a/test/integration/tools/ros/test_rosenv.py b/test/integration/tools/ros/test_rosenv.py
index 2865fb6c4..987558edc 100644
--- a/test/integration/tools/ros/test_rosenv.py
+++ b/test/integration/tools/ros/test_rosenv.py
@@ -32,9 +32,12 @@ def test_rosenv():
     assert os.path.exists(conanrosenv_path)
     conanrosenvbuild_path = os.path.join(install_folder, "conanrosenv-build.sh")
     assert os.path.exists(conanrosenvbuild_path)
-    client.run_command(f". \"{conanrosenv_path}\" && env")
     toolchain_path = os.path.join(client.current_folder, "install", "conan", "conan_toolchain.cmake")
-    assert f"CMAKE_TOOLCHAIN_FILE=\"{toolchain_path}\"" in client.out
+    content = client.load(conanrosenvbuild_path)
+    assert f'CMAKE_TOOLCHAIN_FILE="{toolchain_path}"' in content
+    assert 'CMAKE_BUILD_TYPE="Release"' in content
+    client.run_command(f'. "{conanrosenv_path}" && env')
+    assert f"CMAKE_TOOLCHAIN_FILE={toolchain_path}" in client.out
     assert "CMAKE_BUILD_TYPE=Release" in client.out
 
 
diff --git a/test/unittests/conan_build_info/__init__.py b/test/unittests/conan_build_info/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/unittests/conan_build_info/new_build_info_test.py b/test/unittests/model/build_info/new_build_info_test.py
similarity index 100%
rename from test/unittests/conan_build_info/new_build_info_test.py
rename to test/unittests/model/build_info/new_build_info_test.py
diff --git a/test/unittests/model/build_info/test_deduce_locations.py b/test/unittests/model/build_info/test_deduce_locations.py
new file mode 100644
index 000000000..610cd2a87
--- /dev/null
+++ b/test/unittests/model/build_info/test_deduce_locations.py
@@ -0,0 +1,41 @@
+import os
+
+from conan.test.utils.mocks import ConanFileMock
+from conan.test.utils.test_files import temp_folder
+from conans.model.build_info import CppInfo
+from conans.util.files import save
+
+
+def test_deduce_locations():
+    folder = temp_folder()
+    location = os.path.join(folder, "libdir", "mylib.lib")
+    save(location, "")
+
+    cppinfo = CppInfo()
+    cppinfo.libdirs = ["libdir"]
+    cppinfo.libs = ["mylib"]
+    cppinfo.set_relative_base_folder(folder)
+
+    result = cppinfo.deduce_full_cpp_info(ConanFileMock())
+    assert result.location == location.replace("\\", "/")
+    assert result.link_location is None
+    assert result.type == "static-library"
+
+
+def test_deduce_shared_link_locations():
+    folder = temp_folder()
+    imp_location = os.path.join(folder, "libdir", "mylib.lib")
+    save(imp_location, "")
+    location = os.path.join(folder, "bindir", "mylib.dll")
+    save(location, "")
+
+    cppinfo = CppInfo()
+    cppinfo.libdirs = ["libdir"]
+    cppinfo.bindirs = ["bindir"]
+    cppinfo.libs = ["mylib"]
+    cppinfo.set_relative_base_folder(folder)
+
+    result = cppinfo.deduce_full_cpp_info(ConanFileMock())
+    assert result.location == location.replace("\\", "/")
+    assert result.link_location == imp_location.replace("\\", "/")
+    assert result.type == "shared-library"