Setting Up Pelican

Detailing all the fun I’m having setting up Pelican.

After I get this part working, I’m going back to themes. Then I have to figure out how to import my wordpress posts.

Initially, this was all done on a OS X Yosemite machine. Later on, I migrated to El Capitan (beta). Thus far, its all worked fine. Shouldn’t matter, but YMMV.

Installing python

Start by installing python (I started out with python3, but I found that not all packages work properly with python3 - Does anybody understand backwards compatibility?). I also wanted to build python with the openssl pkg from homebrew.

Next we use pip to install virtualenv (keeps our python versions seperated until the packagers figure out how to do it properly)

Create a path to where you want your virtualenv to exist. Then run the virtualenv command with the -p python argument. Its true that is the default, but at some point that may change to become python3 and we don’t want to be caught unawares.

1mkdir -p ~/path/to/pelican/Virtualenv
2cd ~/path/to/pelican/Virtualenv
3virtualenv -p python Pelican-Dev

Bash configuration

Next, we will edit our .bashrc. We want to restrict the ability to use pip outside of virtual environments (this keeps us from modifying the global/system packages, and additionally, ensures that the packages we install are in the virtual environment(s), where they belong).

The bashrc section looks like this:

1## pip should only run if there is a virtualenv currently activated
2export PIP_REQUIRE_VIRTUALENV=true
3## cache pip-installed packages to avoid re-downloading
4export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
5
6syspip () {
7	PIP_REQUIRE_VIRTUALENV="" pip "$@"
8}

Evaluate the changes in your .bashrc

Use the syspip command to install/upgrade the pip, setuptools, and virtualenv pkgs. For now, this is all we want at the global/system level. Everything else belongs in the virtual environment.

Virtualenv

Navigate to the place we will create our pelican virtual environment. Then run virtualenv and pass an argument that is the name of the environment. I chose pelican (I’m known for my creativity).

1cd ~/path/to/pelican/Virtualenvs
2virtualenv pelican

Navigate to the new environment. Evaluate the script bin/activate, as shown. Your prompt should now suggest that you are in the environment you just created. My prompt begins with a (pelican).

1cd pelican
2. bin/activate

Now that we are in our virtual environment, we can use pip to install pelican, markdown, typogrify and any other bits (I’ve included some things that should be covered as dependencies and auto-pulled, but just in case…):

 1(pelican)[louisk@iPwn pelican ]$ pip install markdown typogrify pelican beautifulsoup4 feedgenerator jinja2 pygments docutils pytz blinker unidecode six Markupsafe python-dateutil pillow
 2	Collecting markdown
 3	Downloading Markdown-2.6.2-py2.py3-none-any.whl (157kB)
 4		100% |████████████████████████████████| 159kB 281kB/s
 5	Collecting typogrify
 6	Downloading typogrify-2.0.7.tar.gz
 7	Collecting pelican
 8	Downloading pelican-3.6.0-py2.py3-none-any.whl (525kB)
 9		100% |████████████████████████████████| 528kB 652kB/s
10	Requirement already satisfied (use --upgrade to upgrade):
11	beautifulsoup4 in ./lib/python.4/site-packages
12	Collecting feedgenerator
13	Downloading feedgenerator-1.7.tar.gz
14	Collecting jinja2
15	Downloading Jinja2-2.7.3.tar.gz (378kB)
16		100% |████████████████████████████████| 380kB 618kB/s
17	Collecting pygments
18	Downloading Pygments-2.0.2-py3-none-any.whl (672kB)
19		100% |████████████████████████████████| 675kB 272kB/s
20	Collecting docutils
21	Downloading docutils-0.12-py3-none-any.whl (508kB)
22		100% |████████████████████████████████| 512kB 570kB/s
23	Collecting pytz
24	Downloading pytz-2015.4-py2.py3-none-any.whl (475kB)
25		100% |████████████████████████████████| 475kB 634kB/s
26	Collecting blinker
27	Downloading blinker-1.3.tar.gz (91kB)
28		100% |████████████████████████████████| 94kB 1.4MB/s
29	Collecting unidecode
30	Downloading Unidecode-0.04.18.tar.gz (206kB)
31		100% |████████████████████████████████| 208kB 969kB/s
32	Collecting six
33	Downloading six-1.9.0-py2.py3-none-any.whl
34	Collecting Markupsafe
35	Downloading MarkupSafe-0.23.tar.gz
36	Collecting python-dateutil
37	Downloading python_dateutil-2.4.2-py2.py3-none-any.whl (188kB)
38		100% |████████████████████████████████| 192kB 24kB/s
39	Collecting smartypants>=1.8.3 (from typogrify)
40	Downloading smartypants-1.8.6-py2.py3-none-any.whl
41	Building wheels for collected packages: typogrify, feedgenerator, jinja2, blinker, unidecode, Markupsafe
42	Running setup.py bdist_wheel for typogrify
43	Stored in directory:
44	/Users/louisk/Library/Caches/pip/wheels/5c/8d/1a/f43724fb740e9fa3b59ec240b4eb7ebc9d4f6902f736aacba9
45	Running setup.py bdist_wheel for feedgenerator
46	Stored in directory:
47	/Users/louisk/Library/Caches/pip/wheels/13/ec/29/50c8c019310746a1dc184553a3c78ca2ec5117494381555eb7
48	Running setup.py bdist_wheel for jinja2
49	Stored in directory:
50	/Users/louisk/Library/Caches/pip/wheels/b3/c0/62/8908d15b90a7de8bd15e2e6e5f5ba1398c0d9940d62a6bf8f5
51	Running setup.py bdist_wheel for blinker
52	Stored in directory:
53	/Users/louisk/Library/Caches/pip/wheels/50/80/79/716f1148d4a8f868755b05259988deccce37edbfb195ded724
54	Running setup.py bdist_wheel for unidecode
55	Stored in directory:
56	/Users/louisk/Library/Caches/pip/wheels/a8/85/b6/71cbccded974d5a8e15cbe7d22066d87f34329d98c7ed5d786
57	Running setup.py bdist_wheel for Markupsafe
58	Stored in directory:
59	/Users/louisk/Library/Caches/pip/wheels/94/a7/79/f79a998b64c1281cb99fa9bbd33cfc9b8b5775f438218d17a7
60	Successfully built typogrify feedgenerator jinja2 blinker
61	unidecode Markupsafe
62	Installing collected packages: markdown, smartypants, typogrify, six, pytz, unidecode, blinker, feedgenerator, Markupsafe, jinja2, python-dateutil, docutils, pygments, pelican
63	Successfully installed Markupsafe-0.23 blinker-1.3 docutils-0.12 feedgenerator-1.7 jinja2-2.7.3 markdown-2.6.2 pelican-3.6.0 pygments-2.0.2 python-dateutil-2.4.2 pytz-2015.4 six-1.9.0 smartypants-1.8.6 typogrify-2.0.7 unidecode-0.4.18
64(pelican)[louisk@iPwn pelican ]$

If you want to use the ‘assets’ plugin for pelican, make sure you install the webassets bits with pip.

 1(pelican)[louisk@iPwn pelican ]$ pip install webassets
 2	Collecting webassets
 3	Downloading webassets-0.10.1.tar.gz (167kB)
 4		100% |████████████████████████████████| 167kB 83kB/s
 5	Building wheels for collected packages: webassets
 6	Running setup.py bdist_wheel for webassets
 7	Stored in directory:
 8	/Users/louisk/Library/Caches/pip/wheels/65/7a/b4/7ef714f1017ea993a1815e61dd334f6195c3d0aadbb2710a55
 9	Successfully built webassets
10	Installing collected packages: webassets
11	Successfully installed webassets-0.10.1

The list of python plugins I’m currently using is

 1beautifulsoup4
 2blinker
 3blockdiag
 4blockdiagcontrib-cisco
 5blockdiagcontrib-class
 6blockdiagcontrib-excelhogan
 7blockdiagcontrib-excelshape
 8blockdiagcontrib-labeledbox
 9blockdiagcontrib-square
10blockdiagcontrib-tex
11docutils
12feedgenerator
13funcparserlib
14jdcal
15Jinja2
16Markdown
17MarkupSafe
18microdata
19nwdiag
20openpyxl
21pelican
22Pillow
23pip
24Pygments
25python-dateutil
26pytz
27setuptools
28seqdiag
29six
30smartypants
31typogrify
32Unidecode
33virtualenv
34webassets
35webcolors
36wheel

Plugins and themes

Now we can get to creating the site we’ll use for pelican I dumped mine into the current directory. I made git clones of the pelican-themes and pelican-plugins directories. Then I copied things around as appropriate, anytime I wanted to make changes to something.

Pelican docs

The docs for setting up pelican are here If you’ve followed the instructions above, you can skip the part about installing pelican, that’s already done. You can jump in with creating a directory for your site, and from that directory, running:

This will create a skeleton collection of files you can start working with including a development “web server” so you can create your new site and see what it will look like.

Development server

The development web server is nice, but I will point out that there can be times when it doesn’t log what its doing, and you have to do something arcane like watch the CPU to know when its done. If you try to view the site (in your browser) before that, you will get lots of errors that don’t make sense. Once the server has finished regenerating everything, things go back to normal.

Moving forward

Now the easy part is done. Its time to start working on the custom bits. You can start digging around in the theme to play with the templates, and the css to get the look you want. You can also look at the plugins. Frequently you will need to modify the templates to take advantage of plugins.

Copyright

Comments