Open Globegitter opened 5 years ago
Hrm... Interesting. Just to make sure I understand: the local pyz_image
with this application did run, but running it via pyz3_image
did not? If you can reproduce the error, could you attach the file list that is generated here? You should be able to run tar tvf bazel-genfiles/(package path)/(binary name).tar
If you could include that file list here, it would help me understand the bug.
In general: this probably means it is either setting PYTHONPATH incorrectly, or it has packaged the files in the wrong locations.
I ran into the same problem with pyz3_image
with this rule setup:
pyz_library(
name = "lib",
srcs = [
"example.py"
],
deps = [
"//third_party/pypi:github3.py",
],
)
pyz_binary(
name = "main",
srcs = [
"main.py",
],
deps = [
":buildlib",
],
)
pyz3_image(
name = "main_image",
binary = ":main",
)
Adding pythonroot="."
to the pyz_library
solved my problem as well.
Ah thanks for this bug report. I think I might know what is going wrong here. For clarity, @ewhauser were these rules in the root of your WORKSPACE
or at some other directory level? Thanks!
Mine were in a subdirectory. I had a lot of problems with the PYTHONPATH using pyz3_image
. The particular app I was using this with worked w/Python 2 as well, so I switched to pyz2_image
which did not have the same problem.
Hrm weird, thanks. I'll see if I can manage to reproduce this somehow ... If you see it again, a standalone git repository that demonstrates the issue means I can definitely figure out how to fix it :)
I was trying to get a legacy app working with these rules (I have not written it myself, it uses Django's manage.py) and to get things working I had to add
pythonroot="."
to my python libraries (otherwise libraries could not be imported). But now running the app in docker via thepyz3_image
complained that it could not import a library, specifically theDJANGO_SETTINGS_MODULE
. Now I additionally added this library without thepythonroot
settings and now it works.I am sorry I can not give more details at this stage I thought I would just report it and if I have more time to investigate I can add more here. I am wondering though if there is a slight difference in the directory layout, or maybe where the process is being executed compared to the runfiles dir locally?