Sunday, July 28, 2019

Getlino now without *.py

I created #3139 and worked on it. Note that when you installed getlino with -e, you must reinstall it after pulling this version to your local copy. See getlino.

Until now, we had to type “getlino.py …” which is less beautiful than “getlino …”. This was because we used the scripts argument in setup.py. I changed it to use entry_points. See here.

Another advantage is that now we can write doctests about getlino. For example:

>>> from getlino.utils import APPNAMES
>>> print(APPNAMES)
['noi', 'voga', 'cosi', 'avanti', 'amici', 'presto', 'weleup', 'welcht', 'min2']

This advantage, however, is for later because currently we want the book test suite to pass also on Python 2.

More advantages will come:

  • we can write unit tests in the getlino repo, and we can probably get travis to setup complete production servers. We should take care to run those tests only on a virtual machine on travis, not on the machine of a developer.

    http://click.palletsprojects.com/en/5.x/testing/

  • we can now use jinja templates in separate files for generating files. Especially for the bash_aliases this will be handy because there we will need more than Python’s basic string formatting.

TODO:

All those pips!

I had a problem on my machine: the following didn’t work though I have python3-pip installed (and though it had been working some time ago):

$ sudo pip3 install -e .
sudo: pip3: command not found

I must say that I previously ran:

$ sudo pip install -U pip

That is, I asked the system-wide pip2 to upgrade itself. Maybe this caused things to break. Anyway, I fixed the problem by uninstalling both system-wide pips and re-installing just pip3:

$ sudo pip remove python-pip python3-pip
$ sudo pip install python3-pip

Note that I also have a pip installed in my default Python environment:

$ which pip
/home/luc/dell1tb/virtualenvs/py3/bin/pip

I uninstalled it using pip uninstall pip because I thought “maybe the system-wide pip alse works for the currently active environment”. But nope. Yes, the uninstall worked, but it left me with a virtualenv without pip. Saying “pip” now meant that I want to install the system-wide Python:

$ which pip
/usr/local/bin/pip
luc@doll:~/work/blog$ which pip3
/usr/bin/pip3

I had to read the docs and install pip again into my default environment. virtualenv automatically installs pip into every new virgin environment.

Getlino documentation

I reviewed the getlino page and renamed --prod to --asroot because this seems to say more accurately what does. If you don’t specify this option, getlino will not touch any system-wide settings, write only to your user config file, startsite will not install an nginx config file. Basically you can install a full development machine when you don’t specify --asroot (exception: some system packages are required if you want to build the docs or run the test suite, but getlino will issue a warning which lists them).

I pushed my changes but did not test very thoroughly.