Reputation: 1396
I have a .mat file in my package that I want to be including when I build the package. I do this with
data_files=[('utide', ['utide/ut_constants.mat'])],
This builds just fine. The question I then have is, when I try to load in the mat file with scipy IO, I have no idea where this file is located, and how I should code it in to be proper. Do I just find the files buildpath and hard code it in? Or is there some more pythonic way to do this?
For anyone interested, the code can be found here.
Upvotes: 0
Views: 253
Reputation: 879501
Since ut_constants.mat
will be in the utide
package directory, you could specify its path like this:
import utide
import os
matfile = os.path.join(os.path.dirname(os.path.abspath(utide.__file__)),
'ut_constants.mat')
If you wish to define matfile
in __init__.py
, then you can find out where utide
has been installed by looking at the special variable __file__
:
matfile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'ut_constants.mat')
Upvotes: 1