[PYTHON] The story of debugging in the local environment because the compilation did not work with Read the Docs

tl;dr

problem

What i did

As stated in the Official Documentation (http://docs.readthedocs.io/en/latest/builds.html), RTD fully publishes its documentation build instructions. In addition, the docker image of the environment used for build is also released, so it is easy to create an equivalent environment at hand and debug it. ..

First, pull the docker image and launch it in an interactive shell.

docker run -it readthedocs/build:latest /bin/bash

By the way, at the time of writing this article, the tag of 2.0 was latest.

Next, execute the command based on the build log of the management screen. Normally, you can read the official build method from python, but since it is troublesome, execute it while filling the line spacing appropriately from the directory name etc.

export READTHEDOCS=1  #Additions
mkdir -p /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs  #Additions
git checkout https://github.com/koreyou/word_embedding_loader.git /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest
cd /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest  #Additions

python2.7 -mvirtualenv --no-site-packages --no-download /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest 
source /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest/bin/activate  #Additions
python /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest/bin/pip install --use-wheel -U --cache-dir /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/.cache/pip sphinx==1.5.3 Pygments==2.2.0 setuptools==28.8.0 docutils==0.13.1 mkdocs==0.15.0 mock==1.0.1 pillow==2.6.1 readthedocs-sphinx-ext\<0.6 sphinx-rtd-theme\<0.3 alabaster\>=0.7,\<0.8,!=0.7.5 commonmark==0.5.4 recommonmark==0.4.0 
# requirements.Since the path of txt is not specified by itself, requirements as preprocessing.It seems that they are looking for the location of txt
python /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest/bin/pip install --exists-action=w --cache-dir /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/.cache/pip -r/home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/checkouts/latest/requirements.txt
python setup.py install --force 

#originally-b It was readthedocs, but it doesn't work, so I changed it to the standard html
python /home/docs/checkouts/readthedocs.org/user_builds/word-embedding-loader/envs/latest/bin/sphinx-build -T -b html -d _build/doctrees-readthedocs -D language=en . _build/html 

After that, debug with python -m pdb at the procedure where the problem occurred.

By the way, the cause was because I added an extra item to my PATH. (RTD does python setup.py install, so you don't need to add your project's package directory to your PATH)

Recommended Posts

The story of debugging in the local environment because the compilation did not work with Read the Docs
The story that yapf did not work in vscode
The story that sendmail that can be executed in the terminal did not work with cron
The story that `while queue` did not work in python
The story that 2D list replacement did not work in python
I was in trouble because the behavior of docker container did not change
The story of building the fastest Linux environment in the world
The story of sharing the pyenv environment with multiple users
The image is displayed in the local development environment, but the image is not displayed on the remote server of VPS
[Python] Tensorflow 2.0 did not support Python 3.8, so the story of downgrading Python
After creating and applying a virtual environment of python3.8.0, code completion did not work with vscode
The story of not being able to run pygame with pycharm
The story of the release work of the application that Google does not tell
The story of outputting the planetarium master in pdf format with Pycairo
The story of participating in AtCoder
The story of the "hole" in the file
Results that did not get caught in the search with this word
The story of a Parking Sensor in 10 minutes with GrovePi + Starter Kit
The story of using mysqlclient because PyMySQL cannot be used with Django 2.2
The story of an error in PyOCR
I installed Pygame with Python 3.5.1 in the environment of pyenv on OS X
Patch when full text search does not work in GAE / Python local environment
The story of doing deep learning with TPU
Note: Prepare the environment of CmdStanPy with docker
Prepare the execution environment of Python3 with Docker
Read the output of subprocess.Popen in real time
The story of finding the optimal n in N fist
The story of reading HSPICE data in Python
Work in a virtual environment with Python virtualenv.
The story of viewing media files in Django
The story that fits in with pip installation
Chrome cannot be opened with selenium because the version of Chrome driver does not match