George V. Reilly

For Want of a Nail

For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a horseshoe nail.

I want to step down as the webmaster of the Northwest C++ Users’ Group after serving for four years. The NWCPP website is built with the Pelican static site generator. I don’t know who will succeed me as webmaster, but it’s likely that they’ll be a Windows user. Pelican runs fine on Mac and Linux, but Windows support has never been great in Pelican.

I’ve been trying to make sure that Pelican can generate the NWCPP website on Windows. That simple goal cascaded into a series of problems.

First, I had to update the website README, to clarify the in­struc­tions about vir­tualen­vs and custom in­stal­la­tion of various packages.

Then, I had to update my stale ghp-import pull request, which adds Windows support. Ghp-import is used to publish the website’s content on the gh-pages branch.

After that, I tried to get the website to build on Windows. It did at one point, I think, about a year ago. At least, I removed the gra­tu­itious Unixisms from the Fabfile back in April, though I only got around to submitting a pull request for it a few weeks ago.

Getting the website to build required several Windows fixes for Pelican. I had to fix the handling of internal links, which use the syntax {file­name}­path/to/file. Windows backslash path separators worked their way in to various paths, which broke some file generation. I thought it was working at that point, so I built the website and published it with ghp-import, only to find that was no longer serving content. I instantly realized that the CNAME file for GitHub Pages was missing (having painfully debugged that issue a number of months back). That meant that I had to fix some other path handling in Pelican.

At that point, I tried to get the Pelican unit tests to pass, intending to write some new ones for the changes I had made. When I tried to pip install -r de­v_re­quire­ments.txt, I ran into problems trying to install lxml. I quickly found Christoph Gohlke’s Windows binary, but then I had a series of problems with Python Wheels and updating out-of-date in­stal­la­tions of Pip and Setuptools and Virtualenv.

The unit tests didn’t pass—of course. The first big problem that I ran into was that a number of tests generate a tree of content and use git diff to compare the output tree with a reference copy of good output. After I fixed the invocation of git diff, I got a ton of errors, most of which were more path separator issues, Still, I was still getting a lot of errors about "LF will be replaced by CRLF … The file will have its original line endings".

I couldn’t figure out how to invoke git diff to ignore CRLF issues, so I spent a couple of hours trying to compare directory trees with dircmp and difflib. That more or less worked, but I was having difficulty with both ignoring whitespace dif­fer­ences, yet rendering a legible diff. Eventually I realized that I should just use git diff again but filter the errors to remove the CRLF warnings. Hey presto, that worked!

While writing this post, I realized that the mysterious accented filenames that I had been seeing with git status in my Mac’s working copy of Pelican (pelican/tests/output/cus­tom_lo­cale/posts/2010/décembre/ and .../201*/février/) could be stopped by setting core.pre­com­pose­u­ni­code.

All for the want of a nail…

Update: Pull Request for Windows fixes.

Today’s round of fixes led me through fixing the remaining tests; providing a six-based answer to converting a filepath to a file URL; more updates to the website README; fixing some warnings in the NWCPP website; and finding an issue in Pip with unzipping paths that are not ASCII.

blog comments powered by Disqus
Happy 100th Birthday to Auntie Pat » « Review: So, Anyway...