conan icon indicating copy to clipboard operation
conan copied to clipboard

[feature] Support for virtual environments

Open jsallay opened this issue 2 years ago • 9 comments

What is your suggestion?

I work on a open source project (https://github.com/gnuradio/gnuradio) that uses a plugin model and I am trying to convince them to use conan for their package management. People have written hundreds on these plugins which end up compiling to dynamically linked libraries.

There is a workflow that I would like to enable where the user finds a package, "installs" it, and immediately is able to use it along with any other "installed" packages. This is presently difficult in conan because each install is independent. If I do a conan install --requires package1 and later do conan install --requires package2 it produces two sets of conan(run/build).sh scripts. The scripts will have the same names, so I can accidentally overwrite the previous script if I call install from the same folder twice.

I could have the user do a single install command - conan install --requires package1 --requires package2, but as the number of plugins installed grows, this becomes more and more difficult.

There is also the difficulty of managing the environment. The presently defined deployers, install packages to unique folders per package. So even though the vast majority of these packages only need to set a few common variables like LD_LIBRARY_PATH, we need to source a new environment after every install.

It would be really nice to have something that works more like a python venv, where we essentially create an alternate root directory and install everything in there. I could set LD_LIBRARY_PATH=<alt_root>/usr/lib and any package that was installed would be immediately available. I wouldn't have to worry about sourcing a new set of environment variables (unless the package had some non-standard ones, but you could write a check for that).

Another bonus to this approach is that it would make final deployment of an application really easy. In a multistage docker build, we could install the conan packages to this virtual environment in the first stage (also installing the system_requirements to the alt root. A second stage could just copy --from builder <alt_root> /. The final docker image would not need to have conan or anything else installed, it would just contain the final application and its dependencies.

Is there an interest in this feature? I have written a v2.0 conan venv command and a custom deployer that might be useful as a start.

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

jsallay avatar Jan 23 '23 13:01 jsallay