I have a python file i want to run before another ...
# general
g
I have a python file i want to run before another file as a sort of "dependency" - what's the best way to do these? In the example below it would be like "i want to run my migration script"?
Copy code
python_source(
    name="web",
    source="web.py",
    dependencies=["scripts:migrate"]
)
Additionally, it may be other general things i want to run, for example, start a postgres container or rmq container. In make i'd just have commands like
run-db
which i'd do with my
run-web
I think the issue I'm facing stems from the fact that
pants run
can only be passed one target. Is there anyway to say run this then that? Similar to something like
make build run
Is this just something that's out of scope for pants and i should just use a makefile for?
When trying to compose aliases with
&&
similar to node related things, alsod oesn't work
pants run-migrate && pants run-gpm-web
This is basically what i want to achieve but without having to type it out wtice and instead have an alias like
pants gpm-web
which calls that effectively
b
I don't know of a way to run more than one thing, which is also annoying to me! Your question prompted me to finally write up an issue about it: https://github.com/pantsbuild/pants/issues/19403. Thanks! (I hope it's not out of scope 😅 ) For the specific case of wanting web to run migrate, in the short term, can you have
web.py
import a function (e.g.
main
) from
migrate.py
, or have a script that wraps both? Effectively using Python as the command runner, rather than make/shell/pants: e.g.
do_it_all.py
:
Copy code
from . import web, migrate
migrate.main()
web.main()
Not great, though. An another alternative in the short term would be continuing to use an external orchestrator, like make or npm.
👍 1
(We have a similar situation, and, due to historical reasons, have ended up with npm as the command runner)
g
Yeah all good - as long as i'm not missing something in the docs. Really just looks like pants is focusing on build related things and that's okay
Still a huge win moving to pants
🎉 1
Just wanted to make sure I wasn't misunderstanding targets and so forth
👍 1