This isn't necessarily a Tessitura issue, but the issue is popping up whenever I try to use the Tessitura API. I've been using Python to access the REST API and it seems to be working great. Anytime I run a POST or GET request from the PyCharm IDE everything works fine.
Now I am trying to compile my script into an executable file using pyinstaller. I ran into some issues with it missing the modules but now I've gotten so far as it to run the script, but once it hits the Tessitura module and tries to run the _init_.py file it says its missing the pkg_resources module. I looked through the Tessitura _init_.py file and the first thing it tries to do is import the pkg_resources module. The pkg_resources module is found in the site-packages folder in the venv directory right along side the Tessitura module. So I don't know why when I run the script through PyCharm it knows where to find the module but when it runs as an exe it can't find it. Do I need to make a copy of the pkg_resources folder and move it into the Tessitura folder?
Jesse Dillman,
I was interested to see your post. Are you using pip install tessitura to get the tessitura library? Or have you created a Tessitura library of your own?
If you are using the pip install tessitura method, as far as I know, you will be the first person to use the library in the context of compiled (.exe) python application. I'd love to learn some more about what you are doing and am glad to see what I can do to help.
--Tom
Tom,
You were the one who actually provided me the info on the Tessitura Python library. I think back in 2020 you sent me a github link that I think said to use pip to install it.
The nature of this project is pretty simple, we want to perform a data dump from Grouper into our Tessitura database. I've built all the local resources: tables procedures and what not. The python script calls the Grouper API and then I loop through the data and pull out the data points that are then inserted into our Tessitura table using the execute custom procedure method. I don't get any "missing modules" errors when I run it through the pycharm console.
When using pyinstaller, it was initially not recognizing the requests and tessitura modules when I created the exe. I found that I needed to run a --path argument on the pyinstaller to specify the file path for all the project site-packages. So I'm wondering if the same thing needs to be done for the Tessitura module, but I can't seem to figure out how to get that done.
Actually, I'm looking through my messages and I think it was a different Tom Brown who provided me that info. Unless it was you and you're just with a different organization now?
So, cool that you are using this tool. And the application sounds like a lot of fun.
You are likely the first person to try to use this little hack library that was created back in 2018 in the way you are attempting.
You may already know all of this. However, I'd be looking at how pyinstaller handles venv s to gather all of the libraries I need for my project in one python venv. This may be helpful. I'd work on getting just the libraries I'd need in a common virtual environment, and then tell pyinstaller where the virtual environment is, rather than each individual library. This StackOverflow post looks like it may be of some use as well. https://stackoverflow.com/questions/48629486/how-can-i-create-the-minimum-size-executable-with-pyinstaller
Please keep me updated on how this is going.
I'm just at a different organization now.
As a quick hack, you could just copy all of the code in the library into your code. The code is actually very short as you can see.
So not sure what to make of this. Copying the code into my main py script didn't work but it at least helped me identify the main problem. It looks like pyinstaller cannot handle __import__ in the same way it handles regular imports. There are work arounds, but most of it went over my head. So I looked through the API code and even though its using that to import the pkg_resources with a declared namespace, the __name__ namespace isn't actually used anywhere. I commented out that __import__ at the beginning of it and ran it through the virtual console and it worked. Then I compiled it to an exe and that worked too.
So that was my biggest hurdle. Now I just need to figure out how I can create an executable that can be run with arguments cause it's probably not a great idea to have my Grouper and Tessitura credentials hardcoded into the exe cause I'd have to recompile it every few months.
Sounds like you are making good progress!
Here is some information about credential management.
I'd tend to use code environments, password management, and deployment through the automation platform I use called dataiku.
Let us know what you end up deciding to do.