thebookofshaders icon indicating copy to clipboard operation
thebookofshaders copied to clipboard

PDF build fails with IOError on OSX

Open cansik opened this issue 8 years ago • 1 comments

I tried to create the pdf but make does always fail with this error:

Error

Traceback (most recent call last):
  File "src/parseBook.py", line 49, in <module>
    modifiedChapterString = injectShaderBlocks(folder,modifiedChapterString)
  File "src/parseBook.py", line 26, in injectShaderBlocks
    shaderString = open(shaderPath, 'r').read()
IOError: [Errno 2] No such file or directory: './14/texture.frag" data-imgs="hokusai.jpg'
make: *** [all] Error 1

Research

It looks like the script takes a bit too much from the html. In this case it would be a parsing error, so i checked your regex:

shaderFile = re.sub(r'<div class=\"codeAndCanvas\" data=\"(.*)\"></div>', r'\1', line.rstrip())

This regex should filter out the .frag in this line:

<div class="codeAndCanvas" data="texture-resolution.frag" data-imgs="nicephore.jpg"></div>

Problem

Now the problem is:

  1. There is an unescaped / at the end of the query.
  2. The (.*) is too greedy. It does not care about other attributes in the html div.

So the result of the first group is: texture-resolution.frag" data-imgs="nicephore.jpg

Fix

We could try make a stronger regex if we know how the files are named. They just contain -, A-Za-z, . and end with a frag so why don't we just try to match them and leave everything else away?

data=\"([\w\-\.]+frag)\"

Now we can replace the line in the script with a simple regex search and get the filename in the first group value:

shaderFile = re.findall('data=\"([\w\-\.]+frag)\"', line)[0]

Finally it works!...ehm...the generation of the frag's works. I have a .tex file now, but the pdf generation still does not work. If I find the solution I will open another issue.

As a help for other Mac users want to build it themselfs

If you try to make the glslViewer on MacOSX and it does not find the glfw3 library, you have to export the path to it after install (maybe the path is different on your system): export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

~~And you have to install xelatex!~~

cansik avatar Jul 28 '15 15:07 cansik

Ok, so @cansik, as I suggested, I create this PR: https://github.com/patriciogonzalezvivo/thebookofshaders/pull/155, so I think we can close this issue too :wink:!

yvan-sraka avatar Aug 17 '17 17:08 yvan-sraka