Support PyInstaller by using frozen temp path

Issue #36 resolved
Scott Mooney created an issue

Using os.path.dirname(__file__) exclusively makes it impossible to freeze Shady with PyInstaller (and probably other ‘compilers') without putting the ’MASTER_META' file and ‘accel' and ‘glsl' directories alongside the executable. Something like this would fix it but I don’t trust myself to do it without disturbing something:

def PackagePath(relative_path):
  if getattr(sys, 'frozen', False):
    here = getattr(sys, '_MEIPASS', '.')  # sys._MEIPASS contains the temp exe unpack dir
  else:
    here = os.path.dirname(__file__)
  return os.path.abspath(os.path.join(here, relative_path))

Comments (4)

  1. Jeremy Hill

    Which version of Shady is this from, and which file? PackagePath()doesn't use __file__ and hasn't for a long time. Is it possible you've got a pip-installed Shady package hanging over from the distant past, normally ignored but somehow being picked up during the freeze? The only place I find def PackagePath is in Shady.Location, and that uses an inspect implementation rather __file__— for exactly this kind of reason.

  2. Scott Mooney reporter

    Yes, I meant the inspect -based function. It still only looks in the current working directory. I'll create a minimal example and attach it here.

  3. Jeremy Hill

    pyinstaller was tweaked and then merged. To freeze a Shady-dependent application, include the output of Shady.Manifest('pyinstaller') in the datas argument.

  4. Log in to comment