Repository: conan-io/conan
Pull request #16228 (2024-05-09 04:28:53)

[MesonToolchain] Added tools.build:defines conf to 'conan list'
Addition to documentation, follow up to docs#3709

No need to add further info to documentation.

RubenRBS: Seems like it'd be best if you could rebase this into the `release/2.3` branch to be released for the next 2.3.1 release, thanks!

Patch:
diff --git a/conan/api/subapi/local.py b/conan/api/subapi/local.py
index 88ae8a8fe..27ed46e00 100644
--- a/conan/api/subapi/local.py
+++ b/conan/api/subapi/local.py
@@ -111,9 +111,10 @@ class LocalAPI:
             with chdir(conanfile.build_folder):
                 conanfile.test()
 
-    def inspect(self, conanfile_path, remotes, lockfile):
+    def inspect(self, conanfile_path, remotes, lockfile, name=None, version=None, user=None,
+                channel=None):
         app = ConanApp(self._conan_api)
-        conanfile = app.loader.load_named(conanfile_path, name=None, version=None,
-                                          user=None, channel=None, remotes=remotes, graph_lock=lockfile)
+        conanfile = app.loader.load_named(conanfile_path, name=name, version=version, user=user,
+                                          channel=channel, remotes=remotes, graph_lock=lockfile)
         return conanfile
 
diff --git a/conan/cli/commands/export_pkg.py b/conan/cli/commands/export_pkg.py
index c9a6e9438..a47cdfe46 100644
--- a/conan/cli/commands/export_pkg.py
+++ b/conan/cli/commands/export_pkg.py
@@ -46,7 +46,8 @@ def export_pkg(conan_api, parser, *args):
     profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args)
     remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
 
-    conanfile = conan_api.local.inspect(path, remotes, lockfile)
+    conanfile = conan_api.local.inspect(path, remotes, lockfile, name=args.name,
+                                        version=args.version, user=args.user, channel=args.channel)
     # The package_type is not fully processed at export
     if conanfile.package_type == "python-require":
         raise ConanException("export-pkg can only be used for binaries, not for 'python-require'")
diff --git a/conans/__init__.py b/conans/__init__.py
index 9861a62e8..88fe9894e 100644
--- a/conans/__init__.py
+++ b/conans/__init__.py
@@ -2,4 +2,4 @@ CHECKSUM_DEPLOY = "checksum_deploy"  # Only when v2
 REVISIONS = "revisions"  # Only when enabled in config, not by default look at server_launcher.py
 OAUTH_TOKEN = "oauth_token"
 
-__version__ = '2.3.0'
+__version__ = '2.3.1'
diff --git a/conans/model/conf.py b/conans/model/conf.py
index 5098608e9..ef758d342 100644
--- a/conans/model/conf.py
+++ b/conans/model/conf.py
@@ -116,7 +116,7 @@ BUILT_IN_CONFS = {
     "tools.build:compiler_executables": "Defines a Python dict-like with the compilers path to be used. Allowed keys {'c', 'cpp', 'cuda', 'objc', 'objcxx', 'rc', 'fortran', 'asm', 'hip', 'ispc', 'ld', 'ar'}",
     "tools.build:cxxflags": "List of extra CXX flags used by different toolchains like CMakeToolchain, AutotoolsToolchain and MesonToolchain",
     "tools.build:cflags": "List of extra C flags used by different toolchains like CMakeToolchain, AutotoolsToolchain and MesonToolchain",
-    "tools.build:defines": "List of extra definition flags used by different toolchains like CMakeToolchain and AutotoolsToolchain",
+    "tools.build:defines": "List of extra definition flags used by different toolchains like CMakeToolchain, AutotoolsToolchain and MesonToolchain",
     "tools.build:sharedlinkflags": "List of extra flags used by CMakeToolchain for CMAKE_SHARED_LINKER_FLAGS_INIT variable",
     "tools.build:exelinkflags": "List of extra flags used by CMakeToolchain for CMAKE_EXE_LINKER_FLAGS_INIT variable",
     "tools.build:linker_scripts": "List of linker script files to pass to the linker used by different toolchains like CMakeToolchain, AutotoolsToolchain, and MesonToolchain",


Test patch:
diff --git a/conans/test/integration/command/export_pkg_test.py b/conans/test/integration/command/export_pkg_test.py
index af0d6be38..3c52b662e 100644
--- a/conans/test/integration/command/export_pkg_test.py
+++ b/conans/test/integration/command/export_pkg_test.py
@@ -638,3 +638,34 @@ def test_remote_none_tool_requires():
     c.run(f"export-pkg pkg {settings} -s:b compiler.cppstd=17")  # This used to crash
     # No longer crash
     assert "pkg/0.1 (test package): Running test()" in c.out
+
+
+def test_export_pkg_set_version_python_requires():
+    # https://github.com/conan-io/conan/issues/16223
+    c = TestClient(light=True)
+    py_require = textwrap.dedent("""
+        from conan import ConanFile
+
+        class TestBuild:
+            def set_version(self):
+                assert self.version
+
+        class TestModule(ConanFile):
+            name = "pyreq"
+            version = "0.1"
+            package_type = "python-require"
+    """)
+    pkg = textwrap.dedent("""
+        from conan import ConanFile
+
+        class TestPkgConan(ConanFile):
+            name="testpkg"
+            python_requires = "pyreq/0.1"
+            python_requires_extend = "pyreq.TestBuild"
+        """)
+    c.save({"pyreq/conanfile.py": py_require,
+            "pkg/conanfile.py": pkg})
+
+    c.run("create pyreq")
+    c.run("export-pkg pkg --version=1.0+0")
+    assert "conanfile.py (testpkg/1.0+0): Exported package binary" in c.out