I'm studying the Conan package manager.
Its manuals and "getting started" tutorials show that conanfile.py
is usually used to package some C++ code, and conanfile.txt
- is for consuming that package.
This answer states that conanfile.txt
is a simplification of conanfile.py
, used by a consumer code.
I've also found this page, describing how to "translate" conanfile.txt
into conanfile.py
.
But file conanfile.py
, created after that translation is anyway different from file conanfile.py
, that was used to build a package.
My question: is it possible to merge them?
Is it possible to have a single conanfile.py
that would either produce a package, or connect to a remote and download already produced one, depending on conan
invocation?
Yes, it is totally possible to use just one conanfile.py
for both things, not only possible, but recommended.
The Conan 2.0 (beta) docs, already explain a bit better the advantages of using a conanfile.py
also to just "consume" dependencies without really creating packages, see this section in the 2.0 docs
Just one detail, when doing conan install
over a conanfile.py
, you do not install that package created from that conanfile.py
but its dependencies. If you want to install the package created from it, you need to conan install pkg/version@user/channel
(in Conan 1.X) and conan install --require=pkg/version
(in 2.0)