I have a source-only package with the following directory structure:
src (directory containing source files)
conanfile.py
The pkg's recipe conanfile.py
looks like this: (copy everything when doing the pack)
from conans import ConanFile, CMake, tools
class PkgConan(ConanFile):
name = "pkg"
version = "0.0.1"
license = "License of pkg here"
url = "URL of pkg here"
description = "Description of pkg here"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def package(self):
self.copy("*")
def package_info(self):
self.cpp_info.libs = ["pkg"]
My package is consumed by an integration project which copies the pkg's sources in its working directory.
The consumer's recipe conanfile.txt
looks like this:
[requires]
pkg/0.0.1@user/test
[imports]
., * -> ./packages/pkg
When installing the dependencies in the integration project, the pkg's sources are copied in the consumer's working directory as expected.
Consumer's working directory:
packages
pkg
src (directory containing pkg's source files)
conanfile.py
conanfile.txt
Here's my usecase: The pkg
is versioned with git and uploaded to GitHub. I want to have the entire git repository of pkg
in the consumer's working directory instead of only pkg's sources.
Expected consumer's working directory:
packages
pkg (repository cloned from GitHub)
.git
src
conanfile.py
conanfile.txt
??? Is it possible with conan to clone the package repository in the consumer's working directory and also checkout the correct version (e.g. checkout commit/tag corresponding to the required version) instead of using the sources coming from [imports] ., * -> ./packages/pkg
??? E.g. I found a bug in pkg
, I want to correct it in the consumer's context and provide the bugfix back.
It is not possible, at least with the approach you are following and current conan features. There could be other issues, not related to conan, for example, the ".git" folder might not be relocatable to other system.
Then, the approach is relatively fragile if at some point you have settings, options, requirements of different versions, as you could end with different packages, for the same recipe. Remember that 1 recipe => N "binaries". Even if you are not building from sources, this relation is maintained. And of course, trying to use conan for binaries, which is the main use case, will break this.
I think you might be interested in the new SCM feature: https://docs.conan.io/en/latest/creating_packages/package_repo.html#capturing-the-remote-and-commit-from-git-scm-experimental. With this repo the flow would be:
scm
, with auto
field to your recipes. The commit will be captured when the package is created.MyPkg/0.1@user/channel
, which has a dependency to MyDep/0.2@user/channel
.MyDep/0.2@user/channel
, checks its SCM detail with: conan get MyDep/0.2@user/channel
git clone
with those details.MyPkg/0.1@user/channel
works properly with latest changes, of MyDep
, make sure that you run the last step conan export-pkg
over MyDep
, so the latest changes are in the conan local cache.This flow is what the conan Workspaces aims to further automate: https://docs.conan.io/en/latest/developing_packages/workspaces.html. The idea could be to have a conan workspace open MyDep/0.1@user/channel
to automate the above steps, and bring a dependency from the local cache directly to your current user workspace. Note that this is not implemented yet.