I have a Python script which uses openslide-python.
openslide-python requires that OpenSlide binaries are in the DLL search path on Windows.
I am planning to distribute my application in the future and I don't want that users download OpenSlide binaries and set PATH. So I am going to include OpenSlide binaries with my application.
The problem is that PATH has to be set before any imports from OpenSlide occur.
Currently I have the following code (simplified with *):
import os
from io import *
os.environ['PATH'] = os.path.dirname(os.path.realpath(__file__)) + os.sep + 'openslide' + os.pathsep + os.environ[
'PATH']
from openslide import *
I realize that it doesn't correspond with PEP 8, because I have a module level import not at top of file.
Any ideas how to make it nicely?