Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

difference between pyz_binary and pyz_image #35

Open
Globegitter opened this issue Aug 9, 2018 · 5 comments
Open

difference between pyz_binary and pyz_image #35

Globegitter opened this issue Aug 9, 2018 · 5 comments

Comments

@Globegitter
Copy link
Contributor

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 the pyz3_image complained that it could not import a library, specifically the DJANGO_SETTINGS_MODULE. Now I additionally added this library without the pythonroot 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?

@evanj
Copy link

evanj commented Aug 10, 2018

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.

@ewhauser
Copy link

ewhauser commented Aug 30, 2018

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.

@evanj
Copy link

evanj commented Sep 10, 2018

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!

@ewhauser
Copy link

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.

@evanj
Copy link

evanj commented Sep 10, 2018

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 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants