vladris / tinkerer

Python blogging engine
https://vladris.com/tinkerer
Other
305 stars 81 forks source link

Bypassed: Use sphinx 1.7.1 in combination with tinkerer and sphinx 3.1.2 as standalone #117

Open Dutchtallman opened 4 years ago

Dutchtallman commented 4 years ago

This issue is bypassed, not solved. I've posted it anyway, so that others might use the bypass solution described here or can help to get a better solution.

Issue of using sphinx stand alone and in combination with tinkerer

Tinkerer 1.7.2 has Sphinx 1.7.1 as requirement. The latest Sphinx is 3.1.2 (July 2020) and I'm also Sphinx as standalone (without tinkerer) and would like to use the latest version. When I first install sphinx:

pip install sphinx

I get version 3.1.2, but when I also install tinkerer:

pip install tinkerer

The output mentions that sphinx is downgraded to version 1.7.1 due to tinkerer requirements.

Considered but not chosen solutions

A python virtual environment cannot handle this as it can only handle different python versions, e.g. 3.7 and 3.8, but not different module versions. I've also considered pipenv and poetry, but these require configuration files and seems to be more oriented towards developers and I wanted something more simple. A virtual machine like virtualbox seems to be too much overload.

Chosen solution

The chosen solution uses pipx and is described here.

First remove tinkerer and sphinx from your installation:

pip uninstall sphinx
pip uninstall tinkerer

I'm using (K)ubuntu with the aptitude package manager and installed pipx via:

sudo aptitude -y install pipx
pipx ensurepath

Without aptitude, you might want to use apt or apt-get. Pipx can be installed in many other ways, see: pipx .

When I tried tinkerer this way to generate my website, I got error messages, and I found out Tinkerer calls Sphinx via a subprocess (instead of 'within' python), Hence, it breaks out of the pipx virtual python environment... This can be prevented by editing the file (using the nano editor):

nano ~/.local/pipx/venvs/tinkerer/lib/python3.8/site-packages/tinkerer/cmdline.py

and change line 49 from flags = ["sphinx-build"] to:

flags = ["~/.local/pipx/venvs/tinkerer/bin/sphinx-build"]

When you want to use additional modules, you also have to add them in pipx, as for example to add matplotlib:

pipx inject tinkerer requests matplotlib

I also made some changes to the conf.py file, perhaps not needed... but anyway:

source_suffix = ".rst"
master_doc = "master"

Now tinkerer generates my website fluently, using sphinx 1.7.1

I can now also install sphinx latest version:

pip install --upgrade sphinx

which gives me version 3.1.2. And this runs well