Hi there. We have a `shell_command` as a dependenc...
# general
r
Hi there. We have a
shell_command
as a dependency of our
pex_binary
to generate css using tailwind. We're able to get the file into our built pex but we can't seem to get it to the correct path. Is there something we're overlooking with the use of
root_output_directory
here? With the default
/
for
root_output_directory
the css file ends up in our pex at
/src/python/apps/internal_tools/theme/css/dist/styles.css
With
src/python/apps
set as
root_output_directory
we get an error:
Copy code
NoSourceRootError: No source root found for `internal_tools/theme/static/css/dist`.
Our
root_patterns
contains
"src/python/apps"
. This is the `shell_command`:
Copy code
shell_command(
    name="npm_build",
    command="npm run build",
    tools=["npm", "node", "sh"],
    execution_dependencies=[":npm_install", ":tailwind", *template_dirs],
    output_files=["../static/css/dist/styles.css"],
    runnable_dependencies=[":npm", ":node"],
    root_output_directory="/",
)
We tried this as an
adhoc_tool
as well but got the same
NoSourceRootError
. Ultimately we want the file at
/internal_tools/theme/css/dist/styles.css
b
Hmmm, I'm not exactly sure. I'm a bit surprised it ends up at
src/python/apps/internal_tools/...
. Can you share your
pex_binary
target(s)?
r
Copy code
pex_binary(
    name="uvicorn",
    entry_point="uvicorn",
    args=["internal_tools.project.asgi:application", "--port", "3000"],
    dependencies=["./theme/static_src:npm_build_result", ":site"],
)

shell_command(
    name="npm_build",
    command="npm run build",
    tools=["npm", "node", "sh"],
    execution_dependencies=[":npm_install", ":tailwind", *template_dirs],
    output_files=["../static/css/dist/styles.css"],
    runnable_dependencies=[":npm", ":node"],
    root_output_directory="/",
)

experimental_wrap_as_resources(name="npm_build_result", inputs=[":npm_build"])
b
Thanks. I think it'd be helpful to know what the exact pex invocation pants is constructing. You can extract it by running with
pants --keep-sandboxes=always ...
, finding the relevant path in the output, and then looking at the
__run.sh
in that