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

[question] Change package_id() function to consider package_id of one dependency #16237

Closed
1 task done
MTomBosch opened this issue May 10, 2024 · 6 comments
Closed
1 task done
Assignees

Comments

@MTomBosch
Copy link

What is your question?

Hello,
we are using Conan 1 and are using the semver_direct_mode for package_id computation.

Now we have a scenario where for one particular dependency I want to consider also its package_id when computing my own package_id.

Do you have somewhere a code snippet that shows how to accomplish my above goal?

Thank you

Have you read the CONTRIBUTING guide?

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

Hi @MTomBosch

I guess you are looking for something like this?:

def package_id(self):
     self.info.requires["my_dep"].xxx_mode()

Where the modes in https://docs.conan.io/1/creating_packages/define_abi_compatibility.html#versioning-schema can tell you which ones do take into account the package_id of the dependency, in this case full_package_mode or recipe_revision_mode.

Is this what you are looking for?

@MTomBosch
Copy link
Author

Partially. Your solution I was already aware of and sorry for not being clear enough that I would not like to use such a solution.

Using "full package mode" or "recipe revision mode" for that one particular dependency would create too many new package ids for the consumer which I would like to avoid. I would only like to react on changes to the package id (and the semver of the dependent packages). Is that posssible at all?

@memsharded
Copy link
Member

Using "full package mode" or "recipe revision mode" for that one particular dependency would create too many new package ids for the consumer which I would like to avoid. I would only like to react on changes to the package id (and the semver of the dependent packages). Is that posssible at all?

Why? full_package_mode only defines name, version, user, channel and package_id effect. Why this would have more effect on the package_id and create too many different binaries? How is it possible that the package_id of the dependency affects my current binary but the version doesn't?

In any case, yes, you should be able to set individual fields like:

def package_id(self):
    self.info.requires["pkg"].package_id = self.dependencies["pkg"].pref.package_id

Or you could use one of the predefined moedes like full_package_mode and invalidate with =None the fields that you want to ignore.

@MTomBosch
Copy link
Author

The default package id mode that we use is semver_direct_mode and it does not compute the pkg id based on user and channel but full_package_mode does and this would lead to more package ids. But maybe that is even acceptable, I will check this.

And thank you for the other proposal.

@MTomBosch MTomBosch reopened this May 15, 2024
@MTomBosch
Copy link
Author

@memsharded Sorry to bother you again. Using the full_package_mode it is working. Now I wanted to try your proposal with the "self.dependencies" but I am getting following error message:

AttributeError: 'PackageReference' object has no attribute 'package_id'

@memsharded
Copy link
Member

Yes, sorry, my bad, in Conan 1.X it is called PackageReference.id, while in Conan 2.X it is PkgReference.package_id. So please try using .id instead.

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

No branches or pull requests

2 participants