-
Notifications
You must be signed in to change notification settings - Fork 77
Par executables can't find data #43
Comments
Can you use Here's an example where we use |
Actually maybe it's |
Is this in the documentation somewhere? |
@duggelz is the authority on this repo. If not, I think we should track adding it with this issue. |
.par files are not intended (by me, at least), to extract all of their files to disk, that kind of defeats the point. However, the waters are seriously muddied by the Bazel .zip for Windows which does always extract by default, and the various ways to create .par files inside Google that use magic command lines or environment variables to autoextract. So, point 1:
Yes, I should do this. For reference it's like:
This provides a file-like object, which is often good enough. When you really need an actual file, you need an API to materialize that file to disk. The internal Google API is terrible (I can say that because I wrote it) so we don't plan to open-source it. The
This is a valid feature request, but I'm biased by the fact that we're actively trying to move away from this inside Google, because the performance and disk usage implications have become quite severe. It's a balance between programmer ease of use, and performance/resource usage, and Google's position on that line is probably quite different than almost everyone else. |
Slight correction: I personally have less interest in 2, but see how others might. |
A resource API is finally coming to the standard library in Python 3.7, and will be backported to 2.7 and 3.4-3.6. Hallelujah! https://gitlab.com/python-devs/importlib_resources Also, I'm leaning toward a "just extract everything to disk all the time" strategy for this tool, instead of the much more complicated heuristics used inside Google for their performance benefits. At the same time, we're investigating open-sourcing the real PAR file implementation used inside Google. |
@duggelz If it's coming in Python 3.7, that means we'll only have to wait 3-4 years before it makes it into the distroless base images which |
Could someone suggest how to deal with data deps provided by The layout of the unpacked par is as follows:
The models are inside |
Answering my own question after digging through the code some more: pkgutil.get_data("__main__", "tflite_models/detect_float.tflite") gets the data |
if you have a build rule like:
However, It turns out only one of them can work:
Can we have an ultimate example of a python project which uses a simple data file - and it works for both par as well as py_binary? |
Hi, I'm having a similar issue. I have this project tree:
In I've been trying for two hours and I can't figure out how to access the
Attempts:
|
I'm using subpar to generate an independent python executable with Bazel. Unfortunately, it doesn't appear that the resulting par file can find data files referenced by the par_binary() rule.
For example, consider this trivial workspace: foo.tar.gz
The par file is built and runs fine:
However, it appears that the executable is picking up the data files from the local filesystem, not the par file. Switching directories and trying to run the par file from its location produces an error:
The expected behavior would be that the execution of the par file from outside the workspace succeeds just as it does within the workspace.
The text was updated successfully, but these errors were encountered: