Search code examples
conan

Unloading a conan package with its required packages


Is there a way to automatically upload the package created by conan and the packages on which it depends to the repository?

Example: I have a <package-A> that I compiled and it is accordingly not in the repository, then I create a <package-B> that requires <package-A>

If I do conan upload <package-B> --all -r <repository>, then <package-B> will be uploading without problems, but if I then delete both packages and do conan install <package-B> -r <repository>, then there will be an error, because there is neither locally nor in the repository.

EDIT

uilianries said right, but I want to add:

  1. You need to add the -pr parameter to conan lock create so that it does it locally: conan lock create --reference package-b/version@user/channel --lockfile-out=<lockfile-name> -pr=<profile>

  2. conan lock build-order does not need to be done, because it looks for dependencies not locally, but in a remote repository, you need to immediately parse the file obtained from conan lock create ...


Solution

  • There is no a single command with such capability.

    You will need it generate a dependencies graph, then upload one by one:

    conan lock create --reference package-b/version@user/channel

    It will generate conan.lock with all your dependencies graph. Read more about lock command.

    Then, you can generate the build order from conan.lock into a json file:

    conan lock build-order --json build-order.json conan.lock

    Finally, you can iterate the JSON content file and upload one-by-one.

    You can use jq or even a python script to iterate and run conan upload.

    Another option is using Conan API, which is not public, but pretty stable.

    The project conan-package-tools uses the API to upload all dependencies here