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/lock upgrade #17577

Draft
wants to merge 5 commits into
base: develop2
Choose a base branch
from
Draft

Conversation

perseoGI
Copy link
Contributor

Changelog: Feature: New lock upgrade command to automatically upgrade desired dependencies resolving the graph
Docs: TODO

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Fix #16636

The objective of this subcommand is to provide an easy and direct CLI interface to upgrade a (single / multiple) reference(s) in a lockfile:

  • Without needing to previously remove them
  • And without needing to specify to which concrete version to upgrade -> let the graph resolution manages that

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

c.run(f"export libb --version=1.1")
c.run(f"export libb --version=1.2")
c.run(f"export libc --version=1.1")
c.run("lock upgrade . --update-requires=liba/* --update-requires=libb/[*] --update-build-requires=libc/[*]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to check that an --update-xxx doesn't update if the provided version or version range is not in the lockfile, and as such is not removed/unlocked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that case. The case when:

  • The recipe requires() contains a version range that would accept the new versions, like requires("libb/[*]")
  • The conan lock upgrade --update-requires=libb/[>2.0] will not upgrade the existing libb/1.1, even if it is in the recipe valid range.

conan/cli/commands/lock.py Outdated Show resolved Hide resolved
conan/cli/commands/lock.py Outdated Show resolved Hide resolved
@perseoGI perseoGI force-pushed the feature/lock_upgrade branch from eb29a17 to 36b7aa0 Compare January 16, 2025 17:03
@memsharded memsharded mentioned this pull request Jan 20, 2025
1 task
else:
return node.ref.matches(ref, is_consumer=None)
updatable_deps = defaultdict(list)
for node in expand_graph().nodes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a bit overkill, I'd try to leverage the existing conan lock remove functionality.

subparser.add_argument('--update-python-requires', action="append", help='Update python-requires from lockfile')
subparser.add_argument('--update-config-requires', action="append", help='Update config-requires from lockfile')
subparser.add_argument('--build-require', action='store_true', default=False, help='Whether the provided reference is a build-require')
subparser.add_argument('--transitives', action='store_true', default=False, help='Upgrade also transitive dependencies')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably drop the --transitives argument at the moment and focus on just 1 use case to start with, start more minimalistic.

Comment on lines +13 to +14
from conan.internal.model.version import Version
from conan.internal.model.version_range import VersionRange
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have learned these are problematic, and we are moving away of the cli layer importing anything else besides cli and api layers. So the best would be to put the required functionality directly into the api layer

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

Successfully merging this pull request may close these issues.

[question] How to update a reference in a lockfile?
2 participants