.. _external_repo: Recipe and sources in a different repo ====================================== In the previous section we fetched the sources of our library from an external repository. It is a typical workflow for packaging third party libraries. There are two different ways to fetch the sources from an external repository: 1. Using the ``source()`` method as we saw in the previous section: .. code-block:: python from conans import ConanFile, CMake, tools class HelloConan(ConanFile): ... def source(self): self.run("git clone https://github.com/memsharded/hello.git") self.run("cd hello && git checkout static_shared") ... You can also use the :ref:`tools.Git ` class: .. code-block:: python from conans import ConanFile, CMake, tools class HelloConan(ConanFile): ... def source(self): git = tools.Git(folder="hello") git.clone("https://github.com/memsharded/hello.git", "static_shared") ... 2. Using the :ref:`scm attribute ` of the conanfile [EXPERIMENTAL]: .. code-block:: python from conans import ConanFile, CMake, tools class HelloConan(ConanFile): scm = { "type": "git", "subfolder": "hello", "url": "https://github.com/memsharded/hello.git", "revision": "static_shared" } ... Conan will clone the ``scm url`` and will checkout the ``scm revision``. For ``git`` (currently the only supported scm), the ``revision`` field can be: - A commit hash - A branch - A tag The ``source()`` method will be called after the checkout process, so you can still use it to patch something or retrieve more sources, but it is not necessary in most cases.