Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying a custom output for the deployers #13757

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conan/api/subapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def install_sources(self, graph, remotes):

# TODO: Look for a better name
def install_consumer(self, deps_graph, generators=None, source_folder=None, output_folder=None,
deploy=False):
deploy=False, deploy_folder=None):
""" Once a dependency graph has been installed, there are things to be done, like invoking
generators for the root consumer.
This is necessary for example for conanfile.txt/py, or for "conan install <ref> -g
Expand All @@ -63,7 +63,7 @@ def install_consumer(self, deps_graph, generators=None, source_folder=None, outp

# The previous .set_base_folders has already decided between the source_folder and output
if deploy:
base_folder = conanfile.folders.base_build
base_folder = deploy_folder or conanfile.folders.base_build
mkdir(base_folder)
do_deploys(self.conan_api, deps_graph, deploy, base_folder)

Expand Down
6 changes: 5 additions & 1 deletion conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from conan.internal.deploy import do_deploys
from conans.client.graph.install_graph import InstallGraph
from conan.errors import ConanException
from conans.util.files import mkdir


@conan_command(group="Consumer")
Expand Down Expand Up @@ -118,6 +119,8 @@ def graph_info(conan_api, parser, subparser, *args):
help='Print information only for packages that match the patterns')
subparser.add_argument("-d", "--deployer", action="append",
help='Deploy using the provided deployer to the output folder')
subparser.add_argument("--output-deployer",
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
help="Deployer output folder, base build folder by default if not set")
subparser.add_argument("--build-require", action='store_true', default=False,
help='Whether the provided reference is a build-require')
args = parser.parse_args(*args)
Expand Down Expand Up @@ -166,7 +169,8 @@ def graph_info(conan_api, parser, subparser, *args):
clean=args.lockfile_clean)
conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out, os.getcwd())
if args.deployer:
base_folder = os.getcwd()
base_folder = args.output_deployer or os.getcwd()
mkdir(base_folder)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
do_deploys(conan_api, deps_graph, args.deployer, base_folder)

return {"graph": deps_graph,
Expand Down
5 changes: 4 additions & 1 deletion conan/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def install(conan_api, parser, *args):
help='The root output folder for generated and build files')
parser.add_argument("-d", "--deployer", action="append",
help='Deploy using the provided deployer to the output folder')
parser.add_argument("--output-deployer",
help="Deployer output folder, base build folder by default if not set")
parser.add_argument("--build-require", action='store_true', default=False,
help='Whether the provided reference is a build-require')
args = parser.parse_args(*args)
Expand Down Expand Up @@ -86,7 +88,8 @@ def install(conan_api, parser, *args):
generators=args.generator,
output_folder=output_folder,
source_folder=source_folder,
deploy=args.deployer
deploy=args.deployer,
deploy_folder=args.output_deployer
)

out.success("Install finished successfully")
Expand Down
19 changes: 19 additions & 0 deletions conans/test/functional/command/test_install_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,22 @@ def test_deploy_single_package():
c.run("install consumer/conanfile.txt --deploy=direct_deploy --output-folder=output2")
header = c.load("output2/direct_deploy/pkg/include/hi.h")
assert "hi" in header


def test_deploy_output_locations():
tc = TestClient()
deployer = textwrap.dedent("""
def deploy(graph, output_folder, **kwargs):
graph.root.conanfile.output.info(f"Deployer output: {output_folder}")
""")
tc.save({"conanfile.txt": "",
"my_deploy.py": deployer})

tmp_folder = temp_folder()
tc.run(f"install . --deployer=my_deploy -of='{tmp_folder}'")
assert f"Deployer output: {tmp_folder}" in tc.out

deployer_output = temp_folder()
tc.run(f"install . --deployer=my_deploy -of='{tmp_folder}' --output-deployer='{deployer_output}'")
assert f"Deployer output: {deployer_output}" in tc.out
assert f"Deployer output: {tmp_folder}" not in tc.out