Open boussaffawalid opened 2 years ago
Hi @boussaffawalid
I can't reproduce this here. Tried this unit test and it is working fine:
def test_full_package_mode():
# https://github.com/conan-io/conan/issues/11196
c = TestClient()
conanfile = textwrap.dedent("""
from conan import ConanFile
class DemoConan(ConanFile):
name = "demo"
version = "1.0"
settings = "build_type"
requires = "dep/1.0"
def package_id(self):
self.info.requires.full_package_mode()
if self.settings.build_type == "Debug":
compatible_pkg = self.info.clone()
compatible_pkg.settings.build_type = "Release"
self.compatible_packages.append(compatible_pkg)
""")
c.save({"dep/conanfile.py": GenConanfile("dep", "1.0"),
"demo/conanfile.py": conanfile})
c.run("create dep")
c.run("create demo")
c.run("install demo/1.0@ -s build_type=Debug")
assert "Using compatible package" in c.out
Can you please check it? Thanks!
@memsharded I tried the test you provided and it passes.
Could you try the example I provided above ? openssl/3.0.2
is the one from https://conan.io/center/
Yes, works fine with openssl/3.0.2
too.
@memsharded I tired on two different machines, macos and windows 10 and I got the same error. I will try again on a fresh installed ubuntu machine.
Oh, now I see what you mean, I have been able to reproduce. This is the test:
def test_full_package_mode():
# https://github.com/conan-io/conan/issues/11196
c = TestClient()
c.run("config set general.revisions_enabled=True")
c.run("remote add center http://center.conan.io")
conanfile = textwrap.dedent("""
from conan import ConanFile
class DemoConan(ConanFile):
name = "demo"
version = "1.0"
settings = "build_type"
requires = "dep/1.0"
def package_id(self):
self.info.requires.full_package_mode()
if self.settings.build_type == "Debug":
compatible_pkg = self.info.clone()
compatible_pkg.settings.build_type = "Release"
self.compatible_packages.append(compatible_pkg)
""")
c.save({"dep/conanfile.py": GenConanfile("dep", "1.0").with_settings("build_type"),
"demo/conanfile.py": conanfile})
c.run("create dep")
c.run("create dep -s build_type=Debug")
c.run("create demo")
c.run("install demo/1.0@")
c.run("install demo/1.0@ -s build_type=Debug", assert_error=True)
assert "Missing binary" in c.out
c.run("install demo/1.0@ -s demo:build_type=Debug")
assert "Using compatible package" in c.out
This is expected behavior. The fact that you are falling back debug->release in the demo
package doesn't mean that the package_id
for openssl
won't be changing when you change configuration. If the openssl
package_id
changes, and you are factoring it the full reference, include the package_id full_package_mode
into the hash of the demo
package, when you change openssl
from Debug
to Release
, the package_id
of demo
changes. As you can see, passing the -s demo:build_type=Debug
will make it work.
@memsharded now it works! thanks! However, I'm still wondering how to achieve this when creating packages using conan-package-tools. Is that even possible ?
@memsharded now it works! thanks! However, I'm still wondering how to achieve this when creating packages using conan-package-tools. Is that even possible ?
No, I think conan-package-tools does not provision for per-package settings yet, but I am not sure, I don't follow conan-package-tools closely.
Using the conanfile below, I'm trying to make Debug package compatible with Release.
and it works as expected!
I got this in the output,
Now I tried to enable
full_package_mode
in combination withcompatible_packages
, using the followingpackage_id
method.Now it fails with this error:
doing some debugging, I figure out that this issue only happens when the recipe have
requirements
. When I tried to removeself.requires("openssl/3.0.2")
,compatible_packages
works again as expected when used withfull_package_mode