bulky-evening-62934
12/17/2020, 5:24 PMPex
, I add some resource files into the built Pex file, and for some reasons, I need to know their absolute path when running the pex file, how could I get it ? is it under $PEX_ROOT ? by pkg_resources
?witty-crayon-22786
12/17/2020, 5:34 PMpkg_resources
pkg_resources
APIs support doing that transparentlybulky-evening-62934
12/17/2020, 5:38 PMresources.resource_filename()
, but it doesn’t work,
NotImplementedError: resource_filename() only supported for .egg, not .zip
libtest/app/data/style.css
in Pex file, I failed to run resources.resource_filename("<http://libtest.app|libtest.app>", "data/style.css")
resources.resource_string("<http://libtest.app|libtest.app>", "data/style.css")
witty-crayon-22786
12/17/2020, 5:42 PMresource_string
etc APIs--unzip, --no-unzip
Whether or not the pex file should be unzipped before
executing it. If the pex file will be run multiple
times under a stable runtime PEX_ROOT the unzipping
will only be performed once and subsequent runs will
enjoy lower startup latency. [Default: do not unzip.]
… then it should automatically extract itself before running.bulky-evening-62934
12/17/2020, 5:45 PMwitty-crayon-22786
12/17/2020, 5:46 PMbulky-evening-62934
12/17/2020, 5:48 PMhundreds-father-404
12/17/2020, 6:17 PManother way might be just passing those resource files along with pex file, it’s less elegant but must work …This is why Pants’s
archive
type exists: https://www.pantsbuild.org/docs/resources#archive-create-a-zip-or-tar-file. It may give some inspiration herebulky-evening-62934
12/17/2020, 6:27 PM