https://pantsbuild.org/ logo
#general
Title
# general
p

purple-plastic-57801

05/16/2023, 12:07 AM
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

broad-processor-92400

05/16/2023, 12:10 AM
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

purple-plastic-57801

05/16/2023, 12:28 AM
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

broad-processor-92400

05/16/2023, 12:30 AM
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

purple-plastic-57801

05/16/2023, 12:31 AM
Hmm okay. Can I pass meson -> run_shell_command?
Just trying to get rid of ugly Make + shell script magic in a repository
b

broad-processor-92400

05/16/2023, 12:32 AM
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

purple-plastic-57801

05/16/2023, 12:34 AM
=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

broad-processor-92400

05/16/2023, 12:34 AM
nice!
p

purple-plastic-57801

05/16/2023, 12:43 AM
Thank you stranger.
👍 1