-
Notifications
You must be signed in to change notification settings - Fork 62
[hotfix] Extension example for clean could not import Conan API search #193
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
base: main
Are you sure you want to change the base?
[hotfix] Extension example for clean could not import Conan API search #193
Conversation
Signed-off-by: Uilian Ries <[email protected]>
Yes, it is true that the I understand that this PR will later update the example to use the |
Signed-off-by: Uilian Ries <[email protected]>
@memsharded as far as I see, it comes from conan-io/conan#18726 I could import the search package as in the commit 3005ea6 only to unblock other PRs, then, thinking to update it to conan list in a next PR |
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
recipes = conan_api.search.recipes("*/*", remote=remote) | ||
if recipes and not confirmation("Do you want to remove all the recipes revisions and their packages ones, " | ||
# Get all recipes and packages, where recipe revision is not the latest | ||
pkg_list = conan_api.list.select(ListPattern("*/*#!latest:*#*", rrev=None, prev=None), remote=remote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the whole command implementation sounds a bit too complicated.
For example, it is not necessary to select
all binaries and all revisions here with :*#*
as later only the recipe will be removed (and it will remove all the associated binaries automatically)
Then, it sounds very inefficient to list twice with the */*
pattern. It sounds better to do a recipe revision list only pkg_list = conan_api.list.select(ListPattern("*/*", rrev=None, prev=None)
, then remove all but the latest revision, and for that latest revision list the specific package revisions to remove (!latest
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I have a learn curve just to write this small piece, needing to understand the API class implementation around this example. Let me update according to your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check the commit 48c7135
Signed-off-by: Uilian Ries <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't love that the ListPattern is running twice again for returning the whole Conan cache pkg+versions, but good enough for me for a custom command example
We don't have helpers anymore to filter the latest rrev and later, to filter prev. It looks a bit complex now, but without these methods, my feeling is the code will be harder to understand based on accessing the list index and filtering manually. |
# Get all package revisions from the latest recipe revision, except the latest package revision | ||
pkg_list = conan_api.list.select(ListPattern("*/*:*#!latest", rrev=None, prev=None), remote=remote) | ||
for recipe_ref, recipe_bundle in pkg_list.refs().items(): | ||
pkg_list = PackagesList.prefs(recipe_ref, recipe_bundle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Conan we usually would call this static method from the pkg_list
object itself, but do note that this is still an undocumented method, maybe we need to take a look into it - I think getting the refs and prefs of a pkglist is a valid operation that users might want access to.
We also need to check if the remove
api can be improved
Signed-off-by: Uilian Ries <[email protected]>
@memsharded Please, check the commit 729e9f7. I'm using a single I used |
When pushing the PR #192 , the following error occurred in the CI:
It seems be affected by conan-io/conan#18726