conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] Can VirtualRunEnv/VirtualBuildEnv scripts generation be suppressed for deployers?

Open db4 opened this issue 1 year ago • 5 comments

What is your question?

I'm exporting files from the Conan cache using conan install --requires=pkg/x.x.x --deployer-package pkg/* and deploy() method in pkg recipe. Everything works as expected except conan install also creates conanbuild*, conanrun*, and deactivate* files in the current directory. Can I suppress their generation?

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

db4 avatar Apr 20 '24 17:04 db4

Hi @db4

Yes, I think that if you instantiate VirtualXXXEnv(conanfile) in the deployer, being conanfile the conanfile of the root node of the graph, it will inhibit the creation of those files, in the same way that if you instantiate them (without calling .generate()) in the "consumer" recipe of the graph.

memsharded avatar Apr 21 '24 16:04 memsharded

Hi @memsharded Thanks for the answer but I'm afraid I don't quite understand it. My recipe used for deploying is roughly the following:

from conan import ConanFile
from conan.tools.files import copy
import os


class PkgConan(ConanFile):
    def requirements(self):
        for req in self.conan_data["sources"][self.version]["requirements"]:
            self.requires(req)

    def deploy(self):
        for d in self.dependencies.host.values():
            for f in ["bin", "data", "config"]:
                if d.package_folder:
                    copy(self, "*", src=os.path.join(d.package_folder, f),
                                    dst=os.path.join(self.deploy_folder, f))

I create a package and then deploy files using conan install --requires=... --deployer-package .... How to modify the recipe to prevent conanbuild*, conanrun*, and deactivate* generation?

db4 avatar Apr 22 '24 08:04 db4

I misunderstood, I thought that you were using an external --deployer

It is not possible to deactivate that from the recipe, you can:

  • Define a conanfile.py with the requires you want instead of the --requires arguments and use it as conan install <path> instead, and define generate() there to deactivate the generation of those files.
  • Write an external deployer to run with --deployer that implements the deactivation

We might be considering other built-ins way to deactivate the environment generation, but not a high priority.

memsharded avatar Apr 22 '24 08:04 memsharded

We might be considering other built-ins way to deactivate the environment generation, but not a high priority.

Ok. Then leave this issue open?

db4 avatar Apr 22 '24 11:04 db4

yes, can be left open, thanks

memsharded avatar Apr 22 '24 12:04 memsharded

This PR https://github.com/conan-io/conan/pull/16863 is adding a conf that disables the generation of those scripts

memsharded avatar Sep 02 '24 09:09 memsharded