Pages

Friday, June 26, 2020

Build latest libvips

As mentioned in the libvips README, you can easily compile libvips if you need a newer version than is provided by your distribution. For example,
FROM ubuntu:18.04

ENV VIPS_VERSION=8.9.2
RUN set -o errexit -o nounset && \
    wget --no-verbose https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz && \
    tar -xf /vips-${VIPS_VERSION}.tar.gz && \
    rm vips-${VIPS_VERSION}.tar.gz && \
    cd vips-${VIPS_VERSION} && \
    ./configure && \
    make && \
    make install && \
    ldconfig && \
    cd .. && \
    rm --recursive vips-${VIPS_VERSION}

But if you want to save some time recompiling (or want a deb for any other reason), you can modify the packaging to use the version you compiled instead. Here's an example with Ubuntu.
# docker build -t vips-deb .
# docker run --rm -v $PWD/debs:/debs vips-deb

FROM ubuntu:18.04

RUN mkdir /debs

WORKDIR /build

RUN set -o errexit -o nounset \
    && apt-get update --yes \
    && apt-get install --no-install-recommends --no-install-suggests --yes \
        build-essential \
        ca-certificates \
        devscripts \
        equivs \
        wget \
    && rm --recursive --force /var/lib/apt/lists/*

# use the Debian version that matches the base image from https://launchpad.net/ubuntu/+source/vips
ENV DEBIAN_VIPS_VERSION=8.4.5-1build1
ENV VIPS_VERSION=8.9.2
RUN set -o errexit -o nounset \
    && wget --no-verbose https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz \
    && tar -xf vips-${VIPS_VERSION}.tar.gz \
    && rm vips-${VIPS_VERSION}.tar.gz \
    && cd vips-${VIPS_VERSION} \
    && wget --no-verbose https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/vips/${DEBIAN_VIPS_VERSION}/vips_${DEBIAN_VIPS_VERSION}.debian.tar.xz \
    && tar -xf vips_${DEBIAN_VIPS_VERSION}.debian.tar.xz \
    && rm vips_${DEBIAN_VIPS_VERSION}.debian.tar.xz \
    && cd debian \
    && EMAIL=john@example.com NAME="John Doe" dch -v ${VIPS_VERSION}-1 "Update to version ${VIPS_VERSION}" \
    && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \
    && apt-get update --yes \
    # don't install Python bindings (this will be supplied by pyvips)
    && sed -Ei '/Package: python-vipscc/,/^$/d' control \
    && mk-build-deps -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' -i control \
    && debuild -i -us -uc -bCMD cp /build/*.deb /debs \
    && rm --recursive --force /var/lib/apt/lists/*

CMD cp --force /build/*.deb /debs
One thing to note, as the Pyvips README says
If you have the development headers for libvips installed and have a working C compiler, this module will use cffi API mode to try to build a libvips binary extension for your Python. If it is unable to build a binary extension, it will use cffi ABI mode instead and only needs the libvips shared library. This takes longer to start up and is typically ~20% slower in execution.
You can confirm whether it is running in ABI mode after installing libvips by running this command
echo -e 'import logging\nlogging.basicConfig(level=logging.DEBUG)\nimport pyvips' | python3
Example ABI Mode Output
DEBUG:pyvips:Binary module load failed: No module named '_libvips'
DEBUG:pyvips:Falling back to ABI mode
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f6c56754978>
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f6c56754860>
DEBUG:pyvips:Inited libvips
Example Non-ABI Mode Output
DEBUG:pyvips:Loaded binary module _libvips
DEBUG:pyvips:Module generated for libvips 8.9
DEBUG:pyvips:Linked to libvips 8.9
DEBUG:pyvips:Inited libvips

Thursday, June 25, 2020

LibreOffice Issues

I don't do much word processing, so I haven't really found it necessary to purchase Microsoft Office.  But recently I did need to do a little editing and unfortunately ran into issues with LibreOffice 6.4.4 on Windows 10.
  1. The UI stopped responding.  The application wasn't froze, I could still click on the text, just wouldn't let me type, clicking toolbars opened an empty grey menu.  When I did Ctrl+S to save my work before bailing on the program, the save dialog opened but it was all grey, no content.  I closed and re-opened the program (closed, not killed) and it didn't prompt me to recover my work.  This happened with both docx and odt.  I asked how I could debug this further.  Update: I haven't seen it yet after resetting my profile (but then I couldn't figure out how to get back out of safe mode, so I ended up uninstalling and reinstalling).
  2. Formatting text inside a cell into columns didn't save.  I selected the text in a cell in a docx document, formatted it into columns and hit save.  Everything looked good, until I closed the doc and opened it again, the column formatting had disappeared.  This was explained by the fact I guess docx can't store that concept. But it's annoying there's no warning when you're saving incompatible stuff to that format.  Most files folks have to interact with are going to be MS Office.  Update: Word behaves strangely with this feature too.  It will let you add column text into a table cell, but it renders in a bizarre way.  So apparently even Word doesn't realize its own format can't handle this, so I guess I can't fault LibreOffice much for this.
  3. Page breaks moved with no changes to the document.  I had an empty page because the previous page had a table that extended to the end of the page (Word always used to do that to me too).  I tried to delete it, but couldn't, no big deal.  What surprised me was I closed the document, then opened it again and the empty page was gone as soon as it opened, no edits made.  This happened in both docx and odt.
I'd been recommending folks use LibreOffice if they wanted a desktop productivity solution (or maybe Word online or Google Docs if their needs were really simple), but I have to re-evaluate that now.  Some of this can affect data integrity, which is concerning.  I'm surprised how many issues I had, given I'm not a heavy user of word processors (I mostly write code not documents).  I'm a fairly technical guy, and if I had trouble, I can only imagine the calls and texts I'd get from my family if I convinced them to move over to this.

Here's an example of the borked UI I was seeing immediately on opening an odt with less than 1000 words.

Here's what Word looks like when you put columns into cells.  And interestingly enough, even though the feature works fine in Writer when using ODT, Google Docs hangs while trying to open the document.  It seems this is a not well supported feature.  Google Docs also appears to apply different spacing to tables (even when the document is just opened and not even edited) compared to both Word and LibreOffice.
Here's the same in Writer in an ODT, which renders as it should
The reason this is useful is using columns can auto arrange the content to the right of the category names in the leftmost cell.

Microsoft's price for Office is kinda steep for the very occasional editing I do, but this experience was more painful than I expected (and there were more differences between the different tools than I would have imagined would be the case in 2020), and neither Google Docs or Word Online have all the features I use in this doc (even though it's not really that complicated, productivity webapps are still pretty primitive from what I've seen).  I'm not sure what I'm gonna do.  It kinda seems like when it comes to sharing documents, it's Microsoft's world and we're just living in it.