Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wanted to share a tip for Linux and OpenImageIO installation #118

Closed
MostHated opened this issue Dec 2, 2021 · 22 comments
Closed

Wanted to share a tip for Linux and OpenImageIO installation #118

MostHated opened this issue Dec 2, 2021 · 22 comments

Comments

@MostHated
Copy link

Hey there,
I just wanted to share with folks who might be having an issue getting OpenImageIO built / installed on linux. If you simply install the Linux version of Homebrew (Linuxbrew), you can install OIIO using brew. It takes a bit (took about 10 minutes) but it will get the job done. 👍

Thanks,
-MH

@github-actions
Copy link

github-actions bot commented Dec 2, 2021

Thank you for opening an issue and helping to make Gimel Studio better!

@Correct-Syntax
Copy link
Member

@MostHated Thanks for the suggestion. 👍 We will look into that.

The difficult part is that we need OpenImageIO built for Python with the extensions for EXR, RAW files and OpenColorIO support.

Do you know offhand if installing via linuxbrew meets those requirements?

@MostHated
Copy link
Author

MostHated commented Dec 2, 2021

Shoot, well, I know I saw EXR in the long list of things during install, but I don't know if it was a dependency of something else and I had closed the terminal after it was done. Is there a way I can check now that I have it installed?

@Correct-Syntax
Copy link
Member

Correct-Syntax commented Dec 2, 2021

Basically, the first thing to check is if it is built with Python support, which you can do quite easily by creating a .py file with import OpenImageIO in it and running it (assuming you have Python installed, of course).

The way to test for EXR support would be to run something like:

import OpenImageIO as oiio
from OpenImageIO import ImageBuf, ImageSpec, ImageBufAlgo

def write_image (image, filename, format=oiio.UNKNOWN) :
    if not image.has_error :
        image.write (filename, format)
    if image.has_error :
        print ("Error writing", filename, ":", image.geterror())

img = ImageBuf ("input.exr")
write_image (img, "output.exr", oiio.FLOAT)

(You will need an EXR file called input.exr in the same directory as the script)

@MostHated
Copy link
Author

MostHated commented Dec 2, 2021

I was taking a look at what it included(openimageio's install guide is what gave me the idea to try it in the first place) :
It had boost-python3, opencolorio, pybind11, open exr, etc listed.

https://formulae.brew.sh/formula/openimageio

I will give what you mentioned a try as well.

@MostHated
Copy link
Author

This is promising, its only telling me it can't find the image. I will try to find one.

@MostHated
Copy link
Author

MostHated commented Dec 2, 2021

Looks like it worked. I grabbed a test image from oiio's repo. I just had to make sure to source the path where the oiio .so library was from brew.

@Correct-Syntax
Copy link
Member

Okay, that is a good sign. Thanks for testing this. 😄

Could you summarize what you did to get it to work so we can test it on our end?

@MostHated
Copy link
Author

Sure thing. This is assuming you already have linux brew installed, as I installed it a long time ago and can't exactly remember if there was anything special about doing so.

# install oiio from brew
brew install openimageio
# Add the location of the oiio library to path
import sys
from os.path import dirname
sys.path.append(dirname('/home/linuxbrew/.linuxbrew/Cellar/openimageio/2.3.9.1/lib/python3.9/site-packages'))

import OpenImageIO as oiio
from OpenImageIO import ImageBuf, ImageSpec, ImageBufAlgo

def write_image(image, filename, format=oiio.UNKNOWN):
    if not image.has_error:
        image.write(filename, format)
    if image.has_error:
        print("Error writing", filename, ":", image.geterror())


img = ImageBuf("input.exr")
write_image(img, "output.exr", oiio.FLOAT)

That was honestly all it took.

This should work as well to make it available to a project.
I am not a python expert, though, by any means, but doing this below allowed me to run the same script you shared in my GimelStudio Pycharm project, which you can see below, even though Pycharm didn't seem to notice it was there.

# copy the resulting oiio library into python virtual environment
cp /home/linuxbrew/.linuxbrew/Cellar/openimageio/2.3.9.1/lib/python3.9/site-packages/OpenImageIO.cpython-39-x86_64-linux-gnu.so /mnt/x/GitHub/GimelStudio/GimelStudio/venv2/lib/python3.9/site-packages/

@MostHated
Copy link
Author

MostHated commented Dec 2, 2021

Nice, it builds and works, too. 👍 👍 I just had to copy over the nodes folder, it kept having an issue with it saying it already existed when building.

Here is that input EXR I got from oiios sample repo.

@Correct-Syntax
Copy link
Member

Thanks for doing this. I am going to work on getting a CI going via Github Actions to automate building the executables soon. I will let you know if I need any further information. 😄

Also, if your willing, you could add the commands you used to install everything and build the executable in the build.py script (it seems similar to the macOs procedure in that script).

@MostHated
Copy link
Author

Yeah, sure thing, would be glad to 👍 .

@MostHated
Copy link
Author

Still working on this, ran into some issues due to pyenv, but I have it nearly worked out.

@MostHated
Copy link
Author

Looks like I got the issue worked out. Turns out that the binary file just really really doesn't like to be started while your current directory is elsewhere. I kept building and testing with:

$ python build.py
$ ./dist/GimelStudio/GimelStudio 

It just wasn't having it. But as soon as I did:

$ python build.py
$ cd dist/GimelStudio
$ ./GimelStudio 

Worked great. I had been fighting with trying to figure out why it was "failing" to build properly, turns out I was just failing to run it right, lol.
I should be able to get things cleaned up and back in order now and hopefully will be good to go.

@iwoithe
Copy link
Member

iwoithe commented Dec 4, 2021

It just wasn't having it

To be honest, it makes sense. The Gimel Studio source code makes use of relative paths. This is why I changed the readme instructions in this commit.

@MostHated
Copy link
Author

So, something I came across that I have been trying to look into is, everything builds solid and works well, but only when not using the --onefile flag. Without it, and dropping the nodes folder into GimelStudio/dist/GimelStudio/nodes it fires up great, you get the console messages:

[INFO] Registered core nodes
[INFO] Registered custom nodes

But when building with --onefile, I get the following when trying to launch the application:

[WARNING] Error registering core nodes:
 No module named 'nodes'
[WARNING] Error registering custom nodes:
 No module named 'nodes'

Traceback (most recent call last):
  File "main.py", line 74, in OnInit
  File "gimelstudio/application.py", line 399, in __init__
  File "gimelstudio/interface/nodegraph_pnl.py", line 57, in __init__
  File "gimelstudio/interface/nodegraph_pnl.py", line 102, in BuildUI
  File "gsnodegraph/graph/base.py", line 671, in AddNode
KeyError: 'corenode_image'
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at /tmp/pip-install-qsybg005/wxpython_f435023263b242dab41e0f141d57147d/ext/wxWidgets/src/common/wincmn.cpp(469) in ~wxWindowBase(): any pushed event handlers must have been removed

I was going to try to see if I could come up with anything, but its getting a bit late, so if it's not something silly that you already know about, I will try to take a peek at it tomorrow.

@Correct-Syntax
Copy link
Member

@MostHated thanks for your perseverance with this. 🙂

Yes I think there is a bug with using the --onefile flag. But, I don't think we need to use that anyway. Not only is there a performance decrease vs the normal build but as you pointed out, the nodes aren't found.

So, if everything else is working with the normal build, feel free to open a PR and we will go from there.

@MostHated
Copy link
Author

Ok, good deal. I wanted to make sure that was ok first before submitting. I am just doing one final test on my laptop, as I never installed brew or pyenv, etc on it, so its more of a fresh/typical test.

@Correct-Syntax
Copy link
Member

Correct-Syntax commented Dec 5, 2021

Okay, sounds great. 👍

Kind of a side question: If I may ask, what's the inspiration for your username? I really hope people don't hate you. 😟

@MostHated
Copy link
Author

Lol, na, quite the opposite, usually. The name was from back when I used to play a lot of PVP in WoW.

I apologize that it's taking a bit longer than expected. I like to be as thorough as I can, though.

The script ensures you are running the correct version of python, then makes sure build-essentials, libgtk3, and GCC are installed (I figured it was a good idea, since my laptop was missing some of them), checks for homebrew, if that's missing, asks to install it. Once detected it builds openimageio, checks for and installs venv if missing (since my laptop was), then goes on to do the actual application build.

All said and done, as long as you have python 3.9, the rest should be taken care of. I just wiped it all out one last time to run through it again after adding the build tools and venv installs, and my laptop isn't the fastest thing in the world, so a run-through takes a little bit.

@MostHated
Copy link
Author

MostHated commented Dec 6, 2021

Ok, finally got things worked out. #121

When I was running things on my desktop, I already had a large number of the dependencies installed, so some of them were not taken into account until I got on my laptop, so I started with a fresh VM and made sure everything worked out of the box on it, starting with the default python3 install it had. (using Pop_OS 21.04)

(Sorry about the commit list, I only ever really commit my own stuff, which is always just me doing whatever, lol, so trying to do it "properly" ended up with me hard resetting my fork 3 times.)

@Correct-Syntax
Copy link
Member

Thanks for your work on this. I think we can now say that we officially have Linux support and it brings us closer to closing that long-standing blocker issue! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants