If I have a pip package that installs a cli tool.....
# general
p
If I have a pip package that installs a cli tool.. how can I use that in pants? I'm attempting to run meson to do some builds via shell_command
b
adhoc_tool
can run pip packages (2.16, in the
pants.backend.experimental.adhoc
backend), e.g. potentially something like
adhoc_tool(runnable="path/to:meson", ...)
where that's the address of the
meson
python_requirement
p
Oh hmm neat! This is in the rigth direction I think..
Copy code
adhoc_tool(
    name = "meson",
    runnable=".build/requirements:reqs-libcamera#meson",
)

run_shell_command(
    name="run-meson",
    command="version",
    runnable_dependencies=[":meson"],
)
I unfortunately get..
Copy code
pants run .build:run-meson
17:30:17.65 [ERROR] 1 Exception encountered:

Engine traceback:
  in `run` goal

ValueError: Address `.build:meson` was specified as a runnable dependency, but is not
runnable.
b
hm, so
adhoc_tool
actually runs the dependency, similar to
shell_command
, just with deeper knowledge of how to set-up and run python deps or similar, so that might need to be:
Copy code
adhoc_tool(
   name="meson-output",
   runnable="...",
   args=["version"],
)
Like
shell_command
,
adhoc_tool
is for codegen though, so `output_files`/`output_directories` is important
p
Hmm okay. Can I pass meson -> run_shell_command?
Just trying to get rid of ugly Make + shell script magic in a repository
b
I wonder if passing the
.build/requirements:reqs-libcamera#meson"
as a
runnable_dependency
to `shell_command`/`run_shell_command` would also work, e.g.
Copy code
run_shell_command(command="meson version", runnable_dependencies=[".build/requirements:reqs-libcamera#meson"])
I don't know exactly the name that that dep will appear on
PATH
, though (e.g. it could be called
reqs-libcamera#meson
literally, I think).
p
=D
Copy code
pants run .build:ruuun-meson
1.0.1
Copy code
run_shell_command(
    name="ruuun-meson",
    command="meson --version",
    runnable_dependencies=[".build/requirements:reqs-libcamera#meson"]
)
🎉 1
Pants is cool. So much easier than bazel 😆
b
nice!
p
Thank you stranger.
👍 1