-
Notifications
You must be signed in to change notification settings - Fork 365
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
Pkg-lists #3257
Merged
Merged
Pkg-lists #3257
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
50b6df2
package lists
memsharded fc4c11a
Merge branch 'release/2.0' into feature/pkglists
memsharded 3d8a3d6
Merge branch 'develop2' into feature/pkglists
memsharded d757b10
pkg-lists docs
memsharded 97d778e
pkg-lists docs
memsharded 4a54f7e
Update examples/commands/pkglists.rst
memsharded 482a16f
Update examples/commands/pkglists.rst
memsharded 74b94c4
Update examples/commands/pkglists.rst
memsharded ae7ad5f
Update examples/commands/pkglists.rst
memsharded 59131e4
Update examples/commands/pkglists.rst
memsharded f9fc964
Update introduction.rst
memsharded e735a07
Update tutorial/other_features.rst
memsharded 99f9e7b
Update examples/commands/pkglists.rst
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.. warning:: | ||
|
||
This feature is experimental and subject to breaking changes. | ||
See :ref:`the Conan stability<stability>` section for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ Examples | |
examples/config_files | ||
examples/graph | ||
examples/dev_flow | ||
examples/commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _examples_commands: | ||
|
||
Conan commands examples | ||
========================= | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
commands/pkglists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
.. _examples_commands_pkglists: | ||
|
||
Using packages-lists | ||
==================== | ||
|
||
.. include:: ../../common/experimental_warning.inc | ||
|
||
|
||
Packages lists are a powerful and convenient Conan feature that allows to automate and concatenate different Conan commands. | ||
Let's see some common use cases: | ||
|
||
|
||
Listing packages and downloading them | ||
------------------------------------- | ||
|
||
A first simple use case could be listing some recipes and/or binaries in a server, and then downloading them. | ||
|
||
We can do any ``conan list``, for example, to list all ``zlib`` versions above ``1.2.11``, the latest recipe revision, | ||
all Windows binaries for that latest recipe revision, and finally the latest package revision for every binary. | ||
Note that if we want to actually download something later, it is necessary to specify the ``latest`` package revision, | ||
otherwise only the recipes will be downloaded. | ||
|
||
.. code-block:: bash | ||
|
||
$ conan list "zlib/[>1.2.11]#latest:*#latest" -p os=Windows --format=json -r=conancenter > pkglist.json | ||
|
||
|
||
The output of the command is sent in ``json`` format to the file ``pkglist.json`` that looks like: | ||
|
||
|
||
.. code-block:: json | ||
:caption: pkglist.json (simplified) | ||
|
||
"conancenter": { | ||
"zlib/1.2.12": { | ||
"revisions": { | ||
"b1fd071d8a2234a488b3ff74a3526f81": { | ||
"timestamp": 1667396813.987, | ||
"packages": { | ||
"ae9eaf478e918e6470fe64a4d8d4d9552b0b3606": { | ||
"revisions": { | ||
"19808a47de859c2408ffcf8e5df1fdaf": { | ||
} | ||
}, | ||
"info": { | ||
"settings": { | ||
"arch": "x86_64", | ||
"os": "Windows" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"zlib/1.2.13": { | ||
} | ||
} | ||
|
||
|
||
The first level in the ``pkglist.json`` is the "origin" remote or "Local Cache" if the list happens in the cache. | ||
In this case, as we listed the packages in ``conancenter`` remote, that will be the origin. | ||
|
||
|
||
We can now do a download of these recipes and binaries with a single ``conan download`` invocation: | ||
|
||
.. code-block:: bash | ||
|
||
$ conan download --list=pkglist.json -r=conancenter | ||
# Download the recipes and binaries in pkglist.json | ||
# And displays a report of the downloaded things | ||
|
||
|
||
Downloading from one remote and uploading to a different remote | ||
--------------------------------------------------------------- | ||
|
||
Let's say that we create a new package list from the packages downloaded in the previous step: | ||
|
||
.. code-block:: bash | ||
|
||
$ conan download --list=pkglist.json -r=conancenter --format=json > downloaded.json | ||
# Download the recipes and binaries in pkglist.json | ||
# And stores the result in "downloaded.json" | ||
|
||
|
||
The resulting ``downloaded.json`` will be almost the same as the ``pkglist.json`` file, but in this case, the "origin" of | ||
those packages is the ``"Local Cache"`` (as the downloaded packages will be in the cache): | ||
|
||
|
||
.. code-block:: json | ||
:caption: downloaded.json (simplified) | ||
|
||
"Local Cache": { | ||
"zlib/1.2.12": { | ||
"revisions": { | ||
} | ||
} | ||
} | ||
|
||
That means that we can now upload this same set of recipes and binaries to a different remote: | ||
|
||
.. code-block:: bash | ||
|
||
$ conan upload --list=downloaded.json -r=myremote -c | ||
# Upload those artifacts to the same remote | ||
|
||
|
||
.. note:: | ||
|
||
**Best practices** | ||
|
||
This would be a **slow** mechanism to run promotions between different server repositories. Servers like | ||
Artifactory provide ways to directly copy packages from one repository to another without using a client, | ||
that are orders of magnitude faster because of file deduplication, so that would be the recommended approach. | ||
The presented approach in this section might be used for air-gapped environments and other situations in which | ||
it is not possible to do a server-to-server copy. | ||
|
||
|
||
|
||
Building and uploading packages | ||
------------------------------- | ||
|
||
One of the most interesting flows is the one when some packages are being built in the local cache, with a | ||
``conan create`` or ``conan install --build=xxx`` command. Typically, we would like to upload the locally built | ||
packages to the server, so they don't have to be re-built again by others. But we might want to upload only | ||
the built binaries, but not all others transitive dependencies, or other packages that we had previously in | ||
our local cache. | ||
|
||
It is possible to compute a package list from the output of a ``conan install``, ``conan create`` and ``conan graph info`` | ||
commands. Then, that package list can be used for the upload. Step by step: | ||
|
||
First let's say that we have our own package ``mypkg/0.1`` and we create it: | ||
|
||
.. code-block:: bash | ||
|
||
$ conan new cmake_lib -d name=mypkg -d version=0.1 | ||
$ conan create . --format=json > create.json | ||
|
||
|
||
This will create a json representation of the graph, with information of what packages have been built ``"binary": "Build"``: | ||
|
||
.. code-block:: json | ||
:caption: create.json (simplified) | ||
|
||
{ | ||
"graph": { | ||
"nodes": { | ||
"0": { | ||
"ref": "conanfile", | ||
"id": "0", | ||
"recipe": "Cli", | ||
"context": "host", | ||
"test": false | ||
}, | ||
"1": { | ||
"ref": "mypkg/0.1#f57cc9a1824f47af2f52df0dbdd440f6", | ||
"id": "1", | ||
"recipe": "Cache", | ||
"package_id": "2401fa1d188d289bb25c37cfa3317e13e377a351", | ||
"prev": "75f44d989175c05bc4be2399edc63091", | ||
"build_id": null, | ||
"binary": "Build" | ||
} | ||
} | ||
} | ||
|
||
|
||
We can compute a package list from this file, and then upload those artifacts to the server with: | ||
|
||
.. code-block:: bash | ||
|
||
$ conan list --graph=create.json --graph-binaries=build --format=json > pkglist.json | ||
# Create a pkglist.json with the known list of recipes and binaries built from sources | ||
$ conan upload --list=pkglist.json -r=myremote -c | ||
|
||
|
||
For more information see the :ref:`Reference commands section<reference_commands>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use the same name for the title and the rest of the mentions.