Replies: 8 comments 4 replies
|
IIUC The difference is control over args. Pants wouldn't know what to pass to |
|
To add to @thejcannon's answer about the background to python_source(
name="generate",
source="generate.py",
dependencies=[
...
]
)
adhoc_tool(
name="generated-docs",
runnable=[":generate"],
output_files=["docs.html"], # change this to match what generate.py produces
)
run_shell_command(
name="publish",
command="firebase deploy --only hosting",
execution_dependencies=[":generated-docs"]
)You'll need to activate the It should also be possible to avoid |
|
@thejcannon @huonw thank you so much for the replies! I think I managed to generate files as a part of I have a python_source(
name="build",
source="build.py",
dependencies=[
...
]
)
adhoc_tool(
name="build-docs",
runnable=":build",
workdir="",
output_directories=["src/py/www/public"]
)
run_shell_command(
name="publish",
command="firebase deploy --only hosting",
execution_dependencies=[
":build-docs"
]
)I run: $ pants run src/py/www:publish
=== Deploying to 'xxx'...
i deploying hosting
Error: Specified "public" directory "public" does not exist, can't deploy hosting to site "xxx"For context, Not sure how the path for generated files in 😞 What is the point of Or why Feels like I'm missing a very critical and important point about how pants works. |
|
Thanks @huonw ! All working now 🥳 Also thanks for the explanation. I makes a bit more sense now. If I think about targets as files it all falls into places a bit neater. Maybe it's all about naming. For example, if I think I understand the difference between P.S. Sorry for grilling you. I would totally understand if you don't want to spend more time explaining it. I find your explanations useful and maybe some of them can be converted into a PR to documentation pages. |
|
Thanks again for the explanation. I think I get the difference a bit better now. Will put it to test next time I write a new BUILD file. It's again a problem of naming for me. 'execution' and 'runnable' have a very similar meaning so the difference between From your own words, |
|
@huonw have issues with a variation on the topic. This time I generate some C code I want to use from Python. I will illustrate the issue with a simpler example. I have:
import os
code = """
def my_sum(a: int, b: int):
return a + b
"""
os.makedirs("build")
with open("build/sum.py", "w") as f:
f.write(code)
from .build.sum import my_sum
if __name__ == "__main__":
print(my_sum(1, 1))and file(
name="gen",
source="gen.py"
)
shell_command(
name="build",
command="python gen.py",
output_dependencies=[
":gen"
],
tools=["python"],
output_directories=["build/"],
)
python_source(
name="run",
source="run.py",
dependencies=[
":build"
]
)
pex_binary(
name="run-pex",
entry_point="run.py",
dependencies=[
":build"
]
)I can do File "/Users/mdp/.pex/unzipped_pexes/e1c0227cf16eb3a5fa0391eb6f11a210182a14a4/gen_test/run.py", line 1, in <module>
from .build.sum import my_sum
ModuleNotFoundError: No module named 'gen_test.build'I tried using experimental_wrap_as_resources(
name="resource-build",
inputs=[":build"],
)
pex_binary(
name="run-pex",
entry_point="run.py",
dependencies=[
":resource-build"
]
)Any suggestions ? |
|
@huonw thanks ! I'm not sure I can reduce it further, it is pretty minimal. I followed your advice with So it actually generates the files, but for some reason puts them into Is it a bug ? |
|
Gist here. The names are a bit different but the behaviour is the same. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi !
I want to use pants to
I tried the following build
Which doesn't seem to work ,
pants run /path/to/build:publishdoes not execute:generate.Would appreciate if someone can explain what I am doing wrong.
Thank you !
All reactions