Monday, 25 June 2018

Import binary package from different directory

I have the following directory structure:

root
  /src
    file1.py
    file2.py
  /libs
    __init__.py
    package.so

I wish to import package.so within file1.py.

I've tried the following import statements to no avail:

from .libs.package import func
from libs.package import func
from .libs import package
from libs import package

I want to avoid having to set PYTHONPATH / sys.path.

Is there a simple way to do this? I assume the issue is due to the package being a shared object and not just a Python file - I don't have access to the source code for it.

Thanks, Adam



from Import binary package from different directory

No comments:

Post a Comment