I mentioned a couple of days ago that my existing workflow for doing pelican blog posts required me to boot into a linux VM usually, as I'm most often running Windows (at least for now...) Getting everything set up so I can run on my Windows host required a little bit of fiddling around.
My setup might be a little unusual though - I run a lot of tools under cygwin (can't live without my bash prompt.) So I do have Python 2.7.8 installed already under Cygwin, but I also have Python 3 installed using the regular Windows package (from making some py2exe builds), still the default is Python 2:
$ python Python 2.7.8 (default, Jul 25 2014, 14:04:36) [GCC 4.8.3] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>>
But when I went to make a fresh virtual environment for Pelican's python dependencies I didn't quite notice that it was defaulting to Python 3.
$ virtualenv ENV Using base prefix 'C:\\Python34' New python executable in ENV\Scripts\python.exe Installing setuptools, pip, wheel... ENVdone.
See that C:\Python34 there... Yep, that's where my regular Windows python lives. Of course, I didn't notice this so I activated the virtual environment:
$ source ENV/Scripts/activate (ENV)
Then went to install all the requirements
pip install -r requirements.txt ... Collecting wsgiref==0.1.2 (from -r requirements.txt (line 16)) Downloading wsgiref-0.1.2.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 20, in <module> File "C:\cygwin64\tmp\pip-build-vcbf2ab1\wsgiref\setup.py", line 5, in <module> import ez_setup File "C:\cygwin64\tmp\pip-build-vcbf2ab1\wsgiref\ez_setup\__init__.py", line 170 print "Setuptools version",version,"or greater has been installed." ^ SyntaxError: Missing parentheses in call to 'print'
Dang it. Python 3 moved to requring print statements to act as a function - print("something") instead of just print "something". So it was only then I realised I'm in Python 3 land.
Deleted that virtual environment, and went to start again:
$ virtualenv -p /usr/bin/python2.7.exe ENV The executable /usr/bin/python2.7.exe (from --python=/usr/bin/python2.7.exe) does not exist
and it turns out the virtualenv that I'm accessing under cygwin is the regular windows install as well:
$ which virtualenv /cygdrive/c/Python34/Scripts/virtualenv
And the windows install won't accept Cygwin's unix style paths. pip actually has the same issue, and I couldn't figure a quick way to get the Cygwin/Python2 version of pip & virtualenv running (suspect I would need to run the Cygwin package manager.) But! I was able to force Windows/Python3 to force run virtualenv with my cygwin Python2 using the actual windows path:
$ virtualenv -p "C:\cygwin64\bin\python2.7.exe" ENV New python executable in ENV/bin/python2.7 Also creating executable in ENV/bin/python Installing setuptools, pip, wheel...done. Running virtualenv with interpreter C:\cygwin64\bin\python2.7.exe
$ source ENV/bin/activate (ENV) $ pip install -r requirements.txt
and that all works fine, so when I run Pelican I should be home free right?
$ fab build [localhost] local: pelican -s pelicanconf.py Traceback (most recent call last): ... Exception: Could not find the theme ../pelican-themes/fresh Fatal error: local() encountered an error (return code 1) while executing 'pelican -s pelicanconf.py' Aborting.
Ahh crud, I messed up where my theme was, so I copied that across and tweaked the config file (pelicanconf.py)
$ fab build [localhost] local: pelican -s pelicanconf.py ERROR: Can't find plugin `thumbnailer`: No module named thumbnailer ERROR: Can't find plugin `sitemap`: No module named sitemap Done: Processed 13 articles and 1 pages in 0.63 seconds. Done.
Ahh crud, I messed up where the plugins are (but it's getting close!) pelican-plugins recommends cloning with all the submodules, but I only need two items that are in the base repo:
$ git clone https://github.com/getpelican/pelican-plugins Cloning into 'pelican-plugins'... remote: Counting objects: 3377, done. remote: Total 3377 (delta 0), reused 0 (delta 0), pack-reused 3377 Receiving objects: 100% (3377/3377), 1.82 MiB | 410.00 KiB/s, done. Resolving deltas: 100% (1534/1534), done. Checking connectivity... done.
update my PLUGIN_PATH in pelicanconf.py and I'm away.
$ fab build [localhost] local: pelican -s pelicanconf.py WARNING: sitemap plugin: category/music.html has invalid modification date, WARNING: sitemap plugin: using date value as lastmod. ... EDIT: a whole lot of those invalid modification dates ... Done: Processed 13 articles and 1 pages in 5.84 seconds. Done.
Finally, sorted! I'm assuming the invalid modification date stuff is down to some cygwin / windows chicanery... but further digging is required, but in any case this blog is now built and deployed from Cygwin on Windows.