modern-wolf-36228
09/08/2021, 1:56 PMcurved-television-6568
09/08/2021, 2:00 PMresource
, see https://www.pantsbuild.org/v2.7/docs/resourceshappy-kitchen-89482
09/08/2021, 2:00 PMresources()
targets to have resources embedded in the pex file. This is useful if you're loading the files using pkgutil
or similar.modern-wolf-36228
09/08/2021, 2:02 PMhappy-kitchen-89482
09/08/2021, 2:02 PMfiles()
and resources()
and when you would use eachmodern-wolf-36228
09/08/2021, 2:14 PMmodern-wolf-36228
09/08/2021, 2:25 PMpython_library(dependencies=["./resources"])
pex_binary(
name="binary",
entry_point="__main__.py",
dependencies=["//:asyncpg", "//:python-multipart"],
)
Then I have `potato/resources/BUILD`:
resources(sources=["./emails"])
Then I have `potato/resources/emails/BUILD`:
resources(sources=["*.html", "./logo.png"])
modern-wolf-36228
09/08/2021, 2:25 PMcurved-television-6568
09/08/2021, 2:44 PMhundreds-father-404
09/08/2021, 2:48 PMhundreds-father-404
09/08/2021, 2:51 PMcurved-television-6568
09/08/2021, 2:54 PM$ ./pants dependencies --transitive :binary
(if had in the root, but otherwise, add the path to potato as necessary..)
To inspect your dependencies (what will end up in you pex file)
This will inform you that there’s something amiss…
Exception message: 1 Exception encountered:
InvalidSpecPath: Address spec has un-normalized path part './resources'
curved-television-6568
09/08/2021, 3:02 PM$ ./pants dependencies --transitive :binary
//__main__.py:main
resources
resources/emails/demo.html
resources/emails/logo.png
potato/BUILD
python_library(name="main", dependencies=["resources"])
pex_binary(
name="binary",
entry_point="__main__.py",
# dependencies=["//:asyncpg", "//:python-multipart"],
)
potato/resources/BUILD
resources(sources=[], dependencies=["./emails"])
Notice, that potato is my root where I have pants
.. so adjust paths/targets accordingly if you have them deeper down.curved-television-6568
09/08/2021, 3:03 PM./emails
from sources to dependencies, as you seem to nest resource targets, it is a dependency, not a source.curved-television-6568
09/08/2021, 3:04 PMmodern-wolf-36228
09/08/2021, 3:19 PMmodern-wolf-36228
09/08/2021, 3:20 PMmodern-wolf-36228
09/08/2021, 3:21 PMresources/BUILD
(which make sense 🙂)modern-wolf-36228
09/08/2021, 3:21 PMwitty-crayon-22786
09/08/2021, 4:01 PMwitty-crayon-22786
09/08/2021, 4:01 PMmodern-wolf-36228
09/08/2021, 4:02 PMmodern-wolf-36228
09/08/2021, 4:02 PMwitty-crayon-22786
09/08/2021, 4:02 PM