Monday, July 25, 2016

Bugfix: running commands with options per_project

When running a command on all projects using per_project, then it was no longer possible to run commands with arguments. For example:

$ pp inv ci --today 20160724
usage: per_project [-h] [-s START] [-u UNTIL] [cmd [cmd ...]]
per_project: error: unrecognized arguments: --today 20160724

This was a case for nargs=argparse.REMAINDER.

Help texts

Ticket #985. starts to give first visible results. I am still discovering the general workflow.

I fixed a design flaw: there was only one target per project doctree, but e.g. the doctree of The Lino Book must write a file to both lino.modlib.lino_startup and lino_xl.lib.xl.

I realized that it must not be a builder but a perfectly normal extension which just listens to the html builder and writes its files when that builder finishes.

I renamed the lino.sphinxcontrib.help_text_builder module into lino.sphinxcontrib.help_texts_extractor

I removed the inv bh command since it is no longer needed. The is automatically created at the end of inv bd (though only when all documents have been parsed during that build, i.e. only after inv clean)

A last thing to observe is project interdependency: since the help texts for lino and xl are being updated only when book is being built, there might be side effects for the projects in between. That is, I cannot simply run:

$ pp inv clean bd pd prep test

But must split them at least into these:

$ pp inv clean bd pd
$ pp inv prep test

The most time-consuming part of this ticket is of course yet to do: convert existing code so that it uses the new feature.

Developer’s Guide

Grigorij reported more problems in Writing your own Python fixtures.

The examples in this document were indeed very outdated and failed completely. I invested 3 hourse to give it a profound review, moved it to a directory on its own and added test cases. Actually the filename “dumpy” should also change.

AttributeError: ‘module’ object has no attribute ‘chdir’

Build 439 fails on with the following error:

$ python --version
Python 2.7.3
$ pip --version
pip 1.4.1 from /home/ubuntu/virtualenv/python2.7/lib/python2.7/site-packages (python 2.7)
$ pip install -U setuptools
Downloading/unpacking setuptools from
  Running egg_info for package setuptools
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/home/ubuntu/virtualenv/python2.7/build/setuptools/", line 194, in <module>
        here and os.path.chdir(here)
    AttributeError: 'module' object has no attribute 'chdir'
    Complete output from command python egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/home/ubuntu/virtualenv/python2.7/build/setuptools/", line 194, in <module>

    here and os.path.chdir(here)

AttributeError: 'module' object has no attribute 'chdir'

The same command on my machine works fine:

$ pip install -U setuptools
Collecting setuptools
  Downloading setuptools-25.1.0-py2.py3-none-any.whl (442kB)
    100% |████████████████████████████████| 450kB 532kB/s
Installing collected packages: setuptools
  Found existing installation: setuptools 20.6.7
    Uninstalling setuptools-20.6.7:
      Successfully uninstalled setuptools-20.6.7
Successfully installed setuptools-25.1.0

I tried by inserting “pip install -U pip”, and then it worked. 440. Afterwards I removed that line again and it still worked (441). So the problem seems to have been temporary. I see no other explanation for the moment…