google / subpar

Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.
Apache License 2.0
566 stars 69 forks source link

subpar not working with psycopg2 dependency. #78

Open bajacondor opened 6 years ago

bajacondor commented 6 years ago

I've made a par_binary() called batch-check that has psycopg2 as a dependency. The par bundle seems to be alright but the main import cannot work out the dependencies of psycopg. This is the error I get:

File "batch-check.par/__main__.py", line 6, in <module>
  File "batch-check.par/pypi__psycopg2_2_7_4/psycopg2/__init__.py", line 50, in <module>
ImportError: No module named _psycopg

I can see pypi__psycopg2_2_7_4/psycopg2/_psycopg.so inside the par file, but it appears to be a .so shared library file. I've attached the par file as a zip here because the par file extension is not allowed on github.

Thank you for your help.

kpi-check.zip

duggelz commented 6 years ago

Can you add the following to your par_binary() rule and try again?

par_binary(
    ...
    zip_safe = False,
    ...
)
alecbz commented 6 years ago

Not OP but that gives me:

no such attribute 'zip_safe' in 'py_binary' rule

it looks like subpar is incorrectly trying to pass the zip_safe flag along to py_binary?

edit: Nevermind, I needed to go from 1.0.0 -> 1.3.0. This seems to fix it for me.