straight-action-80318
07/05/2022, 8:58 PMpex_binary
for Python targets. When I run a python_test
, the only files that seem to be visible in the filesystem at runtime are those that I include with files
or similar, but I can see everything when I’m running a Python binary. Is this the expected behavior? I’m not able to get files
or relocate_files
to work here, are there docs about this somewhere I missed?
Specific use case is pointing Flask at a template/static folder, which I’d like to have visible from the root if possible. Other workarounds appear to be passing in a source file path to the executable itself but that complicates the open source release of this code.straight-action-80318
07/05/2022, 10:10 PMstraight-action-80318
07/14/2022, 11:09 PMbroad-processor-92400
07/14/2022, 11:25 PMresources
rather than files
, and that seems to work okay
resources(name="templates", sources=["templates/*"])
python_sources(dependencies=[":templates"])
https://www.pantsbuild.org/docs/assets was what I read to get this going, but I don't remember the detailsstraight-action-80318
07/15/2022, 12:09 AMhappy-kitchen-89482
07/17/2022, 12:46 AM./pants run
?happy-kitchen-89482
07/17/2022, 12:48 AM./pants run
, the cwd is the repo root, so your code can see the real source files. But those aren't what it's running from. Instead it's running from sandboxed sources, so the native hot reloading doesn't work.happy-kitchen-89482
07/17/2022, 12:48 AMhappy-kitchen-89482
07/17/2022, 12:49 AMrestartable = True
on the pex_binary
, then ./pants run
will restart automatically when files change.happy-kitchen-89482
07/17/2022, 12:50 AMhappy-kitchen-89482
07/17/2022, 12:52 AMhappy-kitchen-89482
07/17/2022, 12:53 AMresources
targetshappy-kitchen-89482
07/17/2022, 12:54 AMhappy-kitchen-89482
07/17/2022, 12:54 AMhappy-kitchen-89482
07/17/2022, 12:55 AM./pants run
, the code is loaded from the sandbox, but the cwd is the repo root. So what you're seeing is expected. But note that the files in the repo root are not the ones being "used" by run.happy-kitchen-89482
07/17/2022, 12:56 AMstraight-action-80318
07/17/2022, 7:21 PMstraight-action-80318
07/17/2022, 7:22 PMstraight-action-80318
07/17/2022, 7:24 PMhappy-kitchen-89482
07/18/2022, 3:13 AM--no-process-cleanup
?straight-action-80318
07/18/2022, 3:58 AMsrc/path/to/package/templates
but I was hoping to use relocated_files
in order to move them to the root directory since the open source release shouldn’t/cannot reference src/path/to/
straight-action-80318
07/18/2022, 3:58 AMhappy-kitchen-89482
07/18/2022, 4:06 PMresources
targets, which strip the source root (assuming src/path/to
is a source root?)straight-action-80318
07/18/2022, 4:16 PMhappy-kitchen-89482
07/18/2022, 5:04 PMfiles
in general don't get embedded into .pex files, you have to use resources
, it's a bit of a mess. @bitter-ability-32190 can comment in detail, because I'm not sure how that affects ./pants run
on a pex_binary
target.bitter-ability-32190
07/18/2022, 5:06 PMinclude_files=True
so files should be present in the sandboxhappy-kitchen-89482
07/18/2022, 6:08 PMpackage
into a pex file, right?bitter-ability-32190
07/18/2022, 6:08 PM