I'm hoping to find a simple way to download a file...
# general
p
I'm hoping to find a simple way to download a file from the internet and cache it for future runs. Specifically this file is an executable that runs a DB emulator used in some tests. I know I can create an
ExternalTool
and then a custom rule that uses that tool but that seems like a fair amount of work. What I was hoping for is a
target
type like
download_file
that is similar to
ExternalTool
but I can then just use that as a dependency in tests that require the tool. That seems much easier as I'd pretty much just have to specify a URL and be done while
ExternalTool
requires creating a class and a custom rule and then tests that require it can't do a simple
pants test some/thing/needing/emulator/::
because the custom rule wouldn't be
test
- so I think I'd need to create a new target type too and then connect the rule to the target, etc.
Something like https://www.pantsbuild.org/docs/plugins-codegen would also work (I'm "generating" an executable file by downloading it) but again seems like a long way to go. I think what I want is something like
files
that takes a URL, downloads it and caches it.
h
We are also adding in the next 2-3 days a new plugin hook for doing set up before Pytest runs, which you'll be able to hook into so that you can set up the emulator before
e
IIUC @plain-carpet-73994 explicitly does not want to have to write a rule for this. He wants to just be able to configure it like a files dependency, except remote.
1
👍 1
h
You're right. I read too quickly, sorry. We could implement that via codegen. Not too difficult. The tricky part imo is the nuance of files vs resources and how that should be handled
h
Why does this have anything to do with codegen? There is no source file in play afaict
h
We're converting a URL to a source file. Codegen is how you do that currently Somewhat similar to using codegen for relocated_files