change script location or use custom script?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

change script location or use custom script?

ijbrewster
I am working on packaging an application that uses a library called "harp". This python code loads a library using the CFFI module. This is all well and good, except for one problem: the script containing the initialization code expects to live in:

<wherever>/lib/python3.7/site-packages/harp

As such, it has the following line of code to find the path to the C library .so/.dylib:

path = os.path.join(os.path.dirname(__file__), "../../..")


which, under normal usage, gives it a path to the 'lib' directory. However, once packaged using Pyinstaller, the "__file__" is moved, so the above code ends up pointing to the .app directory (on MacOS X, presumably on windows/linux it would be some other equally incorrect path).

Of course, I could easily fix this by changing that line of code (I'm thinking something like "../lib" might work, but it might take some tweaking), however that would then break things when running my app normally (not through Pyinstaller). So how should I best approach this? Is there a way in Pyinstaller to tell it "this file needs to live here" such that the existing path definition would be correct? Or, alternately, is there a way to say "substitute this custom file?" Or maybe a way to write a hook that would change that one line of code on packaging (hopefully that's all that needs changed)? Thanks.

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.