Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add a mode similar to "recipe_revision_mode"("full_mode"), that doesn't include PREV #16114

Closed
1 task done
db4 opened this issue Apr 19, 2024 · 6 comments · Fixed by #16195
Closed
1 task done
Assignees
Milestone

Comments

@db4
Copy link
Contributor

db4 commented Apr 19, 2024

What is your suggestion?

I already explained my case in #15941: I need to make Release build of some shared libraries to be compatible with Debug build of everything else. To do so I need some support from Conan: a package_id mode that doesn't include requirements' PREV into the package id. For an individual dependency, I can do the following:

    def package_id(self):
        del self.info.settings.build_type
        del self.info.settings.compiler.runtime_type
        info = self.info.requires["some_embedded_pkg"]
        info.recipe_revision_mode()
        info.package_id = None

but it's quite annoying to trace all dependencies manually. I would rather set

core.package_id:default_embed_mode=the_real_recipe_revision_mode

I assume that it's too late to fix (change) recipe_revision_mode behaviour, but maybe adding a new one is acceptable?

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Apr 19, 2024
@memsharded
Copy link
Member

Hi @db4

Thanks for your question. The full_mode includes everything except the package-revision:

 def full_mode(self):
        self.name = self._ref.name
        self.version = self._ref.version
        self.user = self._ref.user
        self.channel = self._ref.channel
        self.package_id = self._package_id
        self.recipe_revision = self._ref.revision

recipe_revision_mode is just an alias to it

Maybe you don't mean PREV but package_id?

@db4
Copy link
Contributor Author

db4 commented Apr 19, 2024

@memsharded
Look at this:

from conan import ConanFile


class PkgConan(ConanFile):
    settings = "os", "arch", "build_type", "compiler"
    name = "pkg"
    package_type = "shared-library"

    def requirements(self):
        self.requires("zlib/1.2.13")
conan create . --version 1.0.0
...
conan list pkg:*
Found 1 pkg/version recipes matching pkg in local cache
Local Cache
  pkg
    pkg/1.0.0
      revisions
        519ed9c49c746725d36aa46cca043639 (2024-04-19 13:53:36 UTC)
          packages
            691a4b22ed0b3cecfdc4401285a0de1e8b69026c
              info
                settings
                  arch: x86_64
                  build_type: Release
                  compiler: msvc
                  compiler.cppstd: 17
                  compiler.runtime: dynamic
                  compiler.runtime_type: Release
                  compiler.version: 193
                  os: Windows
                requires
                  zlib/1.2.13#e377bee636333ae348d51ca90874e353:7bfde258ff4f62f75668d0896dbddedaa7480a0f

7bfde258ff4f62f75668d0896dbddedaa7480a0f is the zlib's PREV
If I add

    def package_id(self):
        info = self.info.requires["zlib"]
        info.recipe_revision_mode()
        info.package_id = None

I get

conan list pkg:*
Found 1 pkg/version recipes matching pkg in local cache
Local Cache
  pkg
    pkg/1.0.0
      revisions
        dbc69bd9bba2e079f2fb8276cb78c66b (2024-04-19 13:58:30 UTC)
          packages
            191072afd148855aa978e7939f4a111934a47655
              info
                settings
                  arch: x86_64
                  build_type: Release
                  compiler: msvc
                  compiler.cppstd: 17
                  compiler.runtime: dynamic
                  compiler.runtime_type: Release
                  compiler.version: 193
                  os: Windows
                requires
                  zlib/1.2.13#e377bee636333ae348d51ca90874e353

zlib's PREV is not included into the package id. That's what I would like to get by default.

@memsharded
Copy link
Member

Package revisions PREV are not designed to be part of the package_id anymore in Conan 2.0, by design.

More explicitly, having more than 1 PREV for a given package_id should be mostly considered a model or process error, that something went wrong in the process. The PREVS haven't been fully removed in Conan 2, because of traceability, but it is really not expected to be used as a mechanism to manage binaries. All the model is already captured in:

  • the recipe-revision captures all the "sources" model, all the inputs at the source level
  • the package-id captures all the configuration (settings, options, confs and dependencies), all the inputs at the configuration level

That means that if you have a given package-id for a given recipe-revision, (that results in a PREV), that binary should never be rebuilt again. In an ideal world, if it was rebuilt it would create exactly the same PREV, but C++ builds are not always deterministic and if re-built, it might result in a new PREV. This is by definition a waste of resources, and not recommended to do, this is why having more than one PREV should be considered a process error, or a escape latch for recovering from disaster situations (like there was a big mistake in the setup/provision of the CI machines, installing the wrong compiler or something, and a forced rebuild of everything without changing the model had to be done).

This is why the PREV has been dropped from the package-id computation, and it is not planned to add it again. The recipe-revision+package-id model is already an "exact" and complete model for modelling package binaries and the package_id.

@db4
Copy link
Contributor Author

db4 commented Apr 19, 2024

Package revisions PREV are not designed to be part of the package_id anymore in Conan 2.0, by design.

I hope so, but then why do I see the difference between

                requires
                  zlib/1.2.13#e377bee636333ae348d51ca90874e353:7bfde258ff4f62f75668d0896dbddedaa7480a0f

and

                requires
                  zlib/1.2.13#e377bee636333ae348d51ca90874e353

above? Maybe I used an incorrect term - I need the dependency's package_id not to be taken into account. I can do this manually (self.info.requires["zlib"].package_id = None) but there is no standard mode to do that.

@memsharded
Copy link
Member

zlib/1.2.13#e377bee636333ae348d51ca90874e353:7bfde258ff4f62f75668d0896dbddedaa7480a0f

  • The e377bee636333ae348d51ca90874e353 is the recipe-revision
  • the 7bfde258ff4f62f75668d0896dbddedaa7480a0f is the package-id

The difference is that you want to be independent of the package_id, not the package-revision/prev, which is very different.

Then it is good, no prob, it is just a small UX issue. I think a new mode independent of the package_id can be added to make it more convenient, let me have a look.

@memsharded
Copy link
Member

#16195 added a new revision_mode, it will be in next Conan 2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants