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

test_requires and some general 2.0 info #2313

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions conan_v2.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _conan_v2:

Road to Conan 2.0
Migrating to 2.0
=================

Conan has started to work on the next major release. We've been gathering feedback
Expand All @@ -9,10 +9,24 @@ behaviors, clean the codebase and add space for new developments. Development is
ongoing and the `Conan 2.0 Tribe <https://conan.io/tribe.html>`_ is having discussions
about it.

In the future, this section will contain relevant information and changes regarding Conan 2.0,
there is a lot of work ahead, as you can see in `our backlog <https://github.com/conan-io/conan/milestones>`_.
Conan 2.0-alpha is already released. You can access its documentation with the right version label.
It can be installed from PyPI with ``pip install conan==2.0.0-alpha1``

Meanwhile, in version 1.23 we have introduced an environment variable to raise errors in case of using features
that will be deprecated in Conan 2.0. Read more about ``CONAN_V2_MODE`` in :ref:`this section <conan_v2_mode>`.
This section summarizes some of the necessary changes during Conan 1.X to be ready to upgrade to Conan 2.0:


- Use generators and helpers only from ``conan.tools.xxxx`` space. All the other ones are going to be removed.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that this list is enough to keep moving, but I think that we must add practical examples of what all these things means in terms of changes in your recipes, how to activate configurations in 2.0 with examples of the Conan commands, and so on... This section is very important so people can understand what migration to 2.0 in practical terms means

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, totally agree. I wanted to at least add some notes as a guideline of things that should be explained, but indeed there is a lot to be added there.

- Use always build and host profiles. You can enable it by passing ``-pr:b=default`` in the command line to most commands.
Do not use ``os_build``, ``arch_build`` anywhere in your recipes or code.
- Use ``self.test_requires()`` to define test requirements instead of the legacy ``self.build_requires(..., force_host_context)``.
- Activate revisions in your Conan configuration.
- Move all your packages to lowercase. Uppercase package names (or versions/user/channel) will not be possible in 2.0.
- Do not use ``self.deps_cpp_info``, ``self.deps_env_info`` or ``self.deps_user_info``. Use the ``self.dependencies`` access to get
information about dependencies.
- Do not use the ``conan copy`` command to change user/channel. Packages will be immutable, and this command will dissapear in 2.0.
Package promotions are generally done in the server side, copying packages from one server repository to another repository.
- Do not use dictionary expressions in your recipe ``settings`` definition (like ``settings = {"os": ["Windows", "Linux"]}``. This
way of limiting supported configurations by one recipe will be removed. Use the ``validate()`` method instead to raise
``ConanInvalidConfiguration`` if strictly necessary to fail fast for unsupported configurations.
- If you are using ``editables``, the external template files are going to be removed. Use the ``layout()`` method definition instead.

Stay tuned!
5 changes: 4 additions & 1 deletion devtools/build_requires.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ be linked to the generated library or other executable we want to deploy to the

def build_requirements(self):
self.build_requires("protobuf/3.6.1") # 'build' context (protoc.exe will be available)
self.build_requires("gtest/0.1", force_host_context=True) # 'host' context (our library will link with it)
self.test_requires("gtest/0.1")

Note: The ``test_requires()``, available from Conan 1.43, is equivalent to the previous ``self.build_requires(, force_host_context=True)``
syntax. As the later is going to dissapear in Conan 2.0, the former ``test_requires()`` form is recommended.


.. image:: ../images/xbuild/conan-cross-build-variables.png
Expand Down
2 changes: 1 addition & 1 deletion reference/conanfile/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ between the current recipe and the dependency. At the moment they can be:

- ``require.direct``: boolean, ``True`` if it is direct dependency or ``False`` if it is a transitive one.
- ``require.build``: boolean, ``True`` if it is a ``build_require`` in the build context, as ``cmake``.
- ``require.test``: boolean, ``True`` if its a ``build_require`` in the host context (argument ``self.requires(..., force_host_context=True)``), as ``gtest``.
- ``require.test``: boolean, ``True`` if its a ``build_require`` in the host context (defined with ``self.test_requires()``), as ``gtest``.

The ``dependency`` dictionary value is the read-only object described above that access the dependency attributes.

Expand Down