Skip to content

Commit 7b1071c

Browse files
authored
Merge pull request #3237 from conan-io/release/2.0
Update develop2 with Release/2.0
2 parents cc1f79f + 5143a67 commit 7b1071c

File tree

14 files changed

+270
-36
lines changed

14 files changed

+270
-36
lines changed

changelog.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ For a more detailed description of the major changes that Conan 2.0 brings, comp
66
2.0.5 (18-May-2023)
77
-------------------
88

9+
- Feature: `-v` argument defaults to the `VERBOSE` level. `#13839 <https://github.com/conan-io/conan/pull/13839>`_
10+
- Feature: Avoid showing unnecessary skipped dependencies. Now, it only shows a list of reference names if exists skipped binaries. They can be completely listed by adding `-v` (verbose mode) to the current command. `#13836 <https://github.com/conan-io/conan/pull/13836>`_
11+
- Feature: Allow step-into dependencies debugging for packages built locally with ``--build`` `#13833 <https://github.com/conan-io/conan/pull/13833>`_ . Docs `here <https://github.com/conan-io/docs/pull/3210>`__
12+
- Feature: Allow non relocatable, locally built packages with ``upload_policy="skip"`` and ``build_policy="missing"`` `#13833 <https://github.com/conan-io/conan/pull/13833>`_ . Docs `here <https://github.com/conan-io/docs/pull/3210>`__
13+
- Feature: Do not move "build" folders in cache when ``package-revision`` is computed to allow locating sources for dependencies debuggability with step-into `#13810 <https://github.com/conan-io/conan/pull/13810>`_
14+
- Feature: New ``settings.possible_values()`` method to query the range of possible values for a setting. `#13796 <https://github.com/conan-io/conan/pull/13796>`_ . Docs `here <https://github.com/conan-io/docs/pull/3212>`__
15+
- Feature: Optimize and avoid hitting servers for binaries when ``upload_policy=skip`` `#13771 <https://github.com/conan-io/conan/pull/13771>`_
16+
- Feature: Partially relativize generated environment .sh shell scripts `#13764 <https://github.com/conan-io/conan/pull/13764>`_
17+
- Feature: Improve settings.yml error messages `#13748 <https://github.com/conan-io/conan/pull/13748>`_
18+
- Feature: Auto create empty ``global.conf`` to improve UX looking for file in home. `#13746 <https://github.com/conan-io/conan/pull/13746>`_ . Docs `here <https://github.com/conan-io/docs/pull/3211>`__
19+
- Feature: Render the profile file name as profile_name `#13721 <https://github.com/conan-io/conan/pull/13721>`_ . Docs `here <https://github.com/conan-io/docs/pull/3180>`__
20+
- Feature: New global custom generators in cache "extensions/generators" that can be used by name. `#13718 <https://github.com/conan-io/conan/pull/13718>`_ . Docs `here <https://github.com/conan-io/docs/pull/3213>`__
21+
- Feature: Improve :command:`conan inspect` output, it now understands `set_name`/`set_version`. `#13716 <https://github.com/conan-io/conan/pull/13716>`_ . Docs `here <https://github.com/conan-io/docs/pull/3204>`__
22+
- Feature: Define new ``self.tool_requires("pkg/<host_version>")`` to allow some tool-requires to follow and use the same version as the "host" regular requires do. `#13712 <https://github.com/conan-io/conan/pull/13712>`_ . Docs `here <https://github.com/conan-io/docs/pull/3223>`__
23+
- Feature: Introduce new ``core:skip_warns`` configuration to be able to silence some warnings in the output. `#13706 <https://github.com/conan-io/conan/pull/13706>`_ . Docs `here <https://github.com/conan-io/docs/pull/3215>`__
24+
- Feature: Add info_invalid to graph node serialization `#13688 <https://github.com/conan-io/conan/pull/13688>`_
25+
- Feature: Computing and reporting the ``overrides`` in the graph, and in the ``graph build-order`` `#13680 <https://github.com/conan-io/conan/pull/13680>`_
26+
- Feature: New ``revision_mode = "scm_folder"`` for mono-repo projects that want to use ``scm`` revisions. `#13562 <https://github.com/conan-io/conan/pull/13562>`_ . Docs `here <https://github.com/conan-io/docs/pull/3218>`__
27+
- Feature: Demonstrate that it is possible to ``tool_requires`` different versions of the same package. `#13529 <https://github.com/conan-io/conan/pull/13529>`_ . Docs `here <https://github.com/conan-io/docs/pull/3219>`__
28+
- Fix: `build_scripts` now set the `run` trait to `True` by default `#13901 <https://github.com/conan-io/conan/pull/13901>`_ . Docs `here <https://github.com/conan-io/docs/pull/3206>`__
929
- Fix: Fix XcodeDeps includes skipped dependencies. `#13880 <https://github.com/conan-io/conan/pull/13880>`_
1030
- Fix: Do not allow line feeds into ``pkg/version`` reference fields `#13870 <https://github.com/conan-io/conan/pull/13870>`_
1131
- Fix: Fix ``AutotoolsToolchain`` definition of ``tools.build:compiler_executable`` for Windows subsystems `#13867 <https://github.com/conan-io/conan/pull/13867>`_

examples/extensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Conan extensions examples
77
:maxdepth: 2
88

99
extensions/commands/custom_commands
10+
extensions/deployers/builtin_deployers
1011
extensions/deployers/custom_deployers

examples/extensions/commands/clean/custom_command_clean_revisions.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
Custom command: Clean old recipe and package revisions
44
======================================================
55

6+
.. note::
7+
8+
This is mostly an example command. The built-in ``conan remove *#!latest`` syntax,
9+
meaning "all revisions but the latest" would probably be enough for this use case,
10+
without needing this custom command.
11+
12+
613
Please, first of all, clone the sources to recreate this project. You can find them in the
714
`examples2.0 repository <https://github.com/conan-io/examples2>`_ in GitHub:
815

@@ -173,6 +180,8 @@ Important classes to manage user input and user output:
173180
Conan public API
174181
++++++++++++++++
175182

183+
.. include:: ../../../../common/experimental_warning.inc
184+
176185
The most important part of this example is the usage of the Conan API via ``conan_api`` parameter. These are some examples
177186
which are being used in this custom command:
178187

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _examples_extensions_builtin_deployers:
2+
3+
4+
Builtin deployers
5+
=================
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
10+
dev/development_deploy
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
.. _examples_extensions_builtin_deployers_development:
2+
3+
4+
Creating a Conan-agnostic deploy of dependencies for developer use
5+
==================================================================
6+
7+
With the ``full_deploy`` deployer it is possible to create a Conan-agnostic copy of dependencies that can be used by developers without even having Conan installed in their computers.
8+
9+
Let's see it with an example. All the source code is in the
10+
`examples2.0 Github repository <https://github.com/conan-io/examples2>`_
11+
12+
.. code-block:: bash
13+
14+
$ git clone https://github.com/conan-io/examples2.git
15+
$ cd examples2/examples/extensions/deployers/development_deploy
16+
17+
In the folder we can find the following ``conanfile.txt``:
18+
19+
.. code-block:: ini
20+
21+
[requires]
22+
zlib/1.2.13
23+
24+
[tool_requires]
25+
cmake/3.25.3
26+
27+
[generators]
28+
CMakeDeps
29+
CMakeToolchain
30+
31+
[layout]
32+
cmake_layout
33+
34+
The folder also contains a standard ``CMakeLists.txt`` and a ``main.cpp`` source file that can create
35+
an executable that links with ``zlib`` library.
36+
37+
We can install the Debug and Release dependencies, and deploy a local copy of the packages with:
38+
39+
.. code-block:: bash
40+
41+
$ conan install . --deploy=full_deploy --build=missing
42+
$ conan install . --deploy=full_deploy -s build_type=Debug --build=missing
43+
44+
This will create the following folders:
45+
46+
.. code-block:: text
47+
48+
├──src
49+
├──build
50+
│ ├──generators
51+
| └── ZLibConfig.cmake
52+
├──full_deploy
53+
│ ├──build
54+
│ │ └──cmake
55+
│ │ └──3.25.3
56+
│ │ └──x86_64
57+
│ │ ├──bin
58+
│ │
59+
│ └──host
60+
│ └──zlib
61+
│ └──1.2.13
62+
│ ├──Debug
63+
│ │ └──x86_64
64+
│ │ ├──include
65+
│ │ ├──lib
66+
│ └──Release
67+
│ └──x86_64
68+
│ ├──include
69+
│ ├──lib
70+
71+
72+
This folder is fully self-contained. It contains both the necessary tools (like ``cmake`` executable), the headers and compiled libraries of ``zlib`` and the necessary files like ``ZLibConfig.cmake`` in the ``build/generators`` folder, that point to the binaries inside ``full_deploy`` with a relative path.
73+
74+
The Conan cache can be removed, and even Conan uninstalled, then the folder could be moved elsewhere in the computer or copied to another computer, assuming it has the same configuration of OS, compiler, etc.
75+
76+
.. code-block:: bash
77+
78+
$ cd ..
79+
$ cp -R development_deploy /some/other/place
80+
$ cd /some/other/place
81+
82+
And the files could be used by developers as:
83+
84+
.. code-block:: bash
85+
:caption: Windows
86+
87+
$ cd build
88+
# Activate the environment to use CMake 3.25
89+
$ generators\conanbuild.bat
90+
$ cmake --version
91+
cmake version 3.25.3
92+
# Configure, should match the settings used at install
93+
$ cmake .. -G \"Visual Studio 17 2022\" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake
94+
$ cmake --build . --config Release
95+
$ Release\compressor.exe
96+
ZLIB VERSION: 1.2.13
97+
98+
99+
The environment scripts in Linux and OSX are not relocatable, because they contain absolute paths and the ``sh`` shell `does not have any way to provide access to the current script directory for sourced files <https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh/29835459#29835459>`_.
100+
101+
This shouldn't be a big blocker, as a "search and replace" with ``sed`` in the generators folder can fix it:
102+
103+
.. code-block:: bash
104+
:caption: Linux
105+
106+
$ cd build/Release/generators
107+
# Fix folders in Linux
108+
$ sed -i 's,{old_folder},{new_folder},g' *
109+
# Fix folders in MacOS
110+
$ sed -i '' 's,{old_folder},{new_folder},g' *
111+
$ source conanbuild.sh
112+
$ cd ..
113+
$ cmake --version
114+
cmake version 3.25.3
115+
$ cmake ../.. -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
116+
$ cmake --build .
117+
$ ./compressor
118+
ZLIB VERSION: 1.2.13
119+
120+
121+
.. note::
122+
123+
**Best practices**
124+
125+
The fact that this flow is possible doesn't mean that it is recommended for the majority of cases.
126+
It has some limitations:
127+
128+
- It is less efficient, requiring an extra copy of dependencies
129+
- Only ``CMakeDeps`` and ``CMakeToolchain`` are relocatable at this moment. For other build system integrations, please create a ticket in Github
130+
- Linux and OSX shell scripts are not relocatable and require a manual ``sed``
131+
- The binary variability is limited to Release/Debug. The generated files are exclusively for the current configuration, changing any other setting (os, compiler, architecture) will require a different deploy
132+
133+
In the general case, normal usage of the cache is recommended. This "relocatable development deployment"
134+
could be useful for distributing final products that looks like an SDK, to consumers of a project not using Conan.

examples/extensions/deployers/sources/custom_deployer_sources.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Conan will look for the specified deployer in a few extra places in order, namel
3131

3232
#. Absolute paths
3333
#. Relative to cwd
34-
#. In the ``[CONAN_HOME]/extensions/deploy`` folder
34+
#. In the ``[CONAN_HOME]/extensions/deployers`` folder
3535
#. Built-in deployers
3636

3737

542 KB
Binary file not shown.
599 KB
Loading

knowledge.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Knowledge
88
:maxdepth: 2
99

1010

11+
knowledge/cheatsheet
1112
knowledge/guidelines
1213
knowledge/faq
1314
knowledge/videos

knowledge/cheatsheet.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
***********
2+
Cheat sheet
3+
***********
4+
5+
This is a visual cheat sheet for basic Conan commands and
6+
concepts which users can print out and use as a handy reference. It is available
7+
as both a PDF and PNG.
8+
9+
:download:`PDF Format <../images/cheatsheet/conan2-cheatsheet-v5.pdf>`
10+
11+
:download:`PNG Format <../images/cheatsheet/conan2-cheatsheet-v5.png>`
12+
13+
.. image:: ../images/cheatsheet/conan2-cheatsheet-v5.png
14+
:height: 600 px
15+
:width: 800 px
16+
:align: center

reference/commands/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ There are 2 built-in deployers:
256256

257257
Some generators might have the capability of redefining the target "package folder". That means that if some other
258258
generator like ``CMakeDeps`` is used that is pointing to the packages, it will be pointing to the local deployed
259-
copy, and not to the original packages in the Conan cache.
259+
copy, and not to the original packages in the Conan cache. See the full example in :ref:`examples_extensions_builtin_deployers_development`.
260260

261261
It is also possible, and it is a powerful extension point, to write custom user deployers.
262262
Read more about custom deployers in :ref:`reference_extensions_deployers`.

reference/extensions/custom_commands.rst

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _reference_commands_custom_commands:
22

33
Custom commands
4-
=================
4+
===============
55

66
It's possible to create your own Conan commands to solve self-needs thanks to Python and Conan public API powers altogether.
77

@@ -17,7 +17,7 @@ existing Conan one: :command:`conan your_command_name`.
1717

1818

1919
Scoping
20-
++++++++++
20+
+++++++
2121

2222
It's possible to have another folder layer to group some commands under the same topic.
2323

@@ -87,7 +87,7 @@ Main decorator to declare a function as a new Conan command. Where the parameter
8787

8888

8989
conan_subcommand(formatters=None)
90-
++++++++++++++++++++++++++++++++++++
90+
+++++++++++++++++++++++++++++++++
9191

9292
Similar to ``conan_command``, but this one is declaring a sub-command of an existing custom command. For instance:
9393

@@ -120,8 +120,53 @@ The command call looks like :command:`conan hello moon`.
120120
Notice that to declare a sub-command is required an empty Python function acts as the main command.
121121

122122

123-
Formatters arguments
124-
++++++++++++++++++++
123+
Argument definition and parsing
124+
-------------------------------
125+
126+
Commands can define their own arguments with the ``argparse`` Python library.
127+
128+
129+
.. code-block:: python
130+
131+
@conan_command(group='Creator')
132+
def build(conan_api, parser, *args):
133+
"""
134+
Command help
135+
"""
136+
parser.add_argument("path", nargs="?", help='help for command')
137+
add_reference_args(parser)
138+
args = parser.parse_args(*args)
139+
# Use args.path
140+
141+
142+
When there are sub-commands, the base command cannot define arguments, only the sub-commands can do it. If you have a set of common arguments to all sub-commands, you can define a function that adds them.
143+
144+
.. code-block:: python
145+
146+
@conan_command(group="MyGroup")
147+
def mycommand(conan_api, parser, *args):
148+
"""
149+
Command help
150+
"""
151+
# Do not define arguments in the base command
152+
pass
153+
154+
@conan_subcommand()
155+
def mycommand_mysubcommand(conan_api: ConanAPI, parser, subparser, *args):
156+
"""
157+
Subcommand help
158+
"""
159+
# Arguments are added to "subparser"
160+
subparser.add_argument("reference", help="Recipe reference or Package reference")
161+
# You can add common args with your helper
162+
# add_my_common_args(subparser)
163+
# But parsing all of them happens to "parser"
164+
args = parser.parse_args(*args)
165+
# use args.reference
166+
167+
168+
Formatters
169+
----------
125170

126171
The return of the command will be passed as argument to the formatters. If there are different formatters that
127172
require different arguments, the approach is to return a dictionary, and let the formatters chose the
@@ -152,8 +197,8 @@ arguments they need. For example, the ``graph info`` command uses several format
152197
"conan_api": conan_api}
153198
154199
155-
Command function arguments
156-
----------------------------
200+
Commands parameters
201+
-------------------
157202

158203
These are the passed arguments to any custom command and its sub-commands functions:
159204

reference/extensions/deployers.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Then every dependency will end up in a folder such as:
3737

3838
``[OUTPUT_FOLDER]/full_deploy/host/dep/0.1/Release/x86_64``
3939

40+
See a full example of the usage of ``full_deploy`` deployer in :ref:`examples_extensions_builtin_deployers_development`.
4041

4142
.. _reference_extensions_deployer_direct_deploy:
4243

@@ -62,7 +63,7 @@ Conan will look in these locations for the deployer in the following order:
6263

6364
#. Absolute paths
6465
#. Relative to cwd
65-
#. In the ``[CONAN_HOME]/extensions/deploy`` folder
66+
#. In the ``[CONAN_HOME]/extensions/deployers`` folder
6667
#. As built-in deployers
6768

6869
Conan will look for a ``deploy()`` method to call for each installed file.

0 commit comments

Comments
 (0)