Pragmatism in the real world

Installing PyMuPDF on a prerelease Python

I recently installed Python 3.13.0 rc2 to test rst2pdf against it and found that I couldn't install PyMyPDF which is required for the tests. $ pip install pymupdf … This is because for a pre-release version, binary wheels are not provided to PyPI for the mupdf dependency which is written in C++. Hence, the compiler needs the headers. On my Mac, I had the CPATH environment variable set to /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include. For mypdf to compile, I… continue reading.

Reinstall pipx apps after Homebrew Python upgrade

I install Python apps on my Mac using pipx like this: pipx install rst2pdf This will then install rst2pdf into its own isolated environment so that its dependencies do not affect and are not affected by any other Python app I have installed. Internally, it creates a venv at /.local/pipx/venvs/rst2pdf with symlinks to the currently installed python in the bin directory: lrwxrwxr-x@ 1 rob staff 10 24 May 2023 python -> python3.11 lrwxrwxr-x@ 1 rob… continue reading.

Background images and multiple styles in rst2pdf

Over the weekend I released rst2pdf 0.99. The list of changes is quite long as it's been over a year since the last release. There are some key things in this release that I'm particularly pleased about including Python 3.9 and 3.10 & Sphinx 4 support, multiple styles in the class directive and the ability to specify background images in the raw:: pdf directive. There's also a number of bug fixes, particular to math rendering… continue reading.

A logo for rst2pdf

All projects seem to have a logo these days, so I asked my friend Jane of iD to create a logo for rst2pdf and she came up with this: This met what I was looking for with a clear design that is related to the what the application does, so thank you Jane. I've set the profile icon for the GitHub organisation and Twitter accounts and we'll be using this in other places as we… continue reading.

Cannot find zlib headers on macOS 10.15 Catalina

My new MacBook Pro 16" comes with Catalina and while setting up Python to develop rst2pdf, I discovered that Pillow wouldn't install. Running setup.py install for pillow … error ERROR: Command errored out with exit status 1: Looking through the long list of red text I came across: The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Aha! The way this was solved on the… continue reading.

Creating virtual environments with Pyenv

rst2pdf is a Python 2 application that we're making compatible with Python 3. When developing Python applications, I've found it useful to be able to switch python versions easily and also set up clean environments to work in. To do this, I currently use pyenv. This is how I set it up: Install Pyenv On my Mac, I install pyenv & its sister project pyenv-virtualenv with Homebrew: $ brew install readline xz $ brew install… continue reading.

Step debugging sphinx-build in PyCharm

I've been trying to solve an issue with the rst2pdf Sphinx extension which allows you to use rst2pdf to create a PDF of your Sphinx documentation rather than using Sphinx's default pdfTeX builder. In order to understand what was happening, I really wanted to inspect variable at certain stages of the process, which is easiest with a step debugger. As I already use PhpStorm for step debugging PHP, I fired up PyCharm and worked out… continue reading.

rst2pdf: back from the dead!

Today marks a momentous day! I've released 0.94 of rst2pdf to PyPI! If you have a need to convert plain text files to PDF, check it out. As the last release, 0.93, was December 2012, I think you could have reasonably assumed that the project was abandoned. So why did I bring it back from the dead?

Automatically converting PDF to Keynote

I use rst2pdf to create presentations which provides me with a PDF file. When it comes to presenting on stage, on Linux there are tools such as pdfpc and on Mac there's Keynote. Keynote doesn't read PDF files by default, so we have to convert them and the tool I use for this is Melissa O'Neill's PDF to Keynote. This is a GUI tool, so I manually create the Keynote file when I need it… continue reading.

Auto reloading a PDF on OS X

Currently, I create presentations using rst2pdf and so I regularly have vim open side by side with the Preview app showing the rendered PDF. I use a Makefile to create the PDF from the rst sources, so I just use :make in vim to rebuild the PDF file and then had to switch to Preview in order for it to reload the updated PDF file. Recently a friend wondered why the PDF viewer couldn't reload… continue reading.