adamant-magazine-16751
10/25/2022, 3:03 PMexperimental_shell_command
that executes python my_script.py
the way to go? What do I do afterwards to access the file?adamant-magazine-16751
10/25/2022, 3:05 PMbitter-ability-32190
10/25/2022, 3:09 PMexperimental_shell_command
does generate files that can be consumed. BUT it literally generates a files
target type, which cannot be treated like a resource
and therefore cannot be packaged in a pex_binary
bitter-ability-32190
10/25/2022, 3:14 PMexperimental_shell_command
, but the output
classvar in the GenerateSourcesRequest
is a resource
.
...in fact I think you can have it be 1 statement long:
class GenResourceTarget(ShellCommandTarget):
alias = "generate_resource`
class GenResourceRequest(GenerateSourcesRequest):
input = ShellCommandSourcesField
output = ResourceSourceField
@rule
async def do_the_thing(request: MyRequestType) -> GeneratedSources:
return await Get(GeneratedSources, GenerateFilesFromShellCommandRequest, request)
def rules():
return [*collect_rules(), UnionRule(GenerateSourcesRequest, GenResourceRequest),]
bitter-ability-32190
10/25/2022, 3:14 PMbitter-ability-32190
10/25/2022, 3:30 PMadamant-magazine-16751
10/25/2022, 3:30 PMbitter-ability-32190
10/25/2022, 3:31 PMpex_binary
you're SoL. If you want the file in an archive
or in a docker_image
(I think) that's actually doable, since those are file
-awareadamant-magazine-16751
10/25/2022, 3:31 PMbitter-ability-32190
10/25/2022, 3:32 PMexperimental_shell_command
WILL be in the Docker build contextbitter-ability-32190
10/25/2022, 4:07 PMdependencies
for your "generator" target will also be dependencies of your thing-that-depends-on-it đbitter-ability-32190
10/25/2022, 4:31 PMpipx
-like tip. Then one about Python GPU support in Pants)happy-kitchen-89482
10/25/2022, 5:12 PMexperimental_shell_command
, and @bitter-ability-32190 has long had thoughts about the mess of files vs resourceshappy-kitchen-89482
10/25/2022, 5:31 PMfiles
canât be embedded in a pex? I get that itâs troublesome in theory, but in practiceâŚbitter-ability-32190
10/25/2022, 5:32 PMfiles
are different form resources. files
are expected to be loaded from disk and not embedded in packages. pex_binary
being like a compiled JAR or a native EXE (with embedded bytes)witty-crayon-22786
10/25/2022, 5:36 PMfiles
in the CWD it is running in so that you could use open
with a relative path, then we could support using files
with PEX⌠but it doesnât right now (and it would be a bit awkward: youâd have to be careful where you ran the PEX not to overwrite stuff in the directory)witty-crayon-22786
10/25/2022, 5:37 PMresources
are always in the PYTHONPATH, and are never (assumed to be) relative to the cwd.witty-crayon-22786
10/25/2022, 5:38 PMresources
or files
could/should change over time (i.e. to be consuming-target-side rather than producing-target-side). iâm just fairly sure we do actually need the split.happy-kitchen-89482
10/25/2022, 5:51 PMbitter-ability-32190
10/25/2022, 5:52 PMwitty-crayon-22786
10/25/2022, 5:52 PMIn practice, if your source root is the repo root, there is no difference, and it looks like Pants is being obstreperousâŚthatâs not true once youâve actually deployed a PEX somewhere. say you run it in your home dir⌠should it extract the
file
into your home dir automatically? should it overwrite whatever is already there?happy-kitchen-89482
10/25/2022, 5:52 PMhappy-kitchen-89482
10/25/2022, 5:54 PM__file__
, why would it need to be extracted to your homedir?witty-crayon-22786
10/25/2022, 5:55 PMfiles
work in test running, with archives, etc.: in those cases, the file is relative to the CWD