*Best practices question! PEX, `run_shell_command`...
# general
m
Best practices question! PEX,
run_shell_command
and going the final mile.
Hello team, I am trying to make deployment automatic from our monorepo. I have two pex targets:
deployer
and
deployee
. I would like to make it easy to devs to deploy from our monorepo using pants something as simple as:
Copy code
pants run server:deploy
The current solution I have is to do
Copy code
run_shell_command(
    name="deploy",
    command="$CHROOT/path.to/deployer.pex $CHROOT/path.to/deployee.pex",
    execution_dependencies=[":deployee", ":deployer"],
)
Is this recommended? Somehow hard coding
$CHROOT
doesn't feel right...
c
unfortunately, I think that's the best I can come up with using
run_shell_command
. You could write a macro to generate these. Here's an example, and the doc for adding macros will help you install it
Copy code
def deployable(deployer, deployee):
    run_shell_command(
        name="deploy",
        command=f"$CHROOT/{deployer}.pex $CHROOT/{deployee}.pex",
        execution_dependencies=[f":{deployee}"],
        runnable_dependencies=[f":{deployer}"]
    )
If you're open to writing plugins, we've got the
experimental-deploy
goal. Implementing it is currently undocumented but I did a writeup as part of an MR. There's a bit more work for packaging the deployee and including it as part of the sandbox. Honestly I think the Macro is probably easier.
m
Thank you Daniel for the kind response. 🙏
❤️ 1