たまたんのぶろぐ

たまたんが時たま言いたいことを書いてます。ジャンルはめっちゃええ加減ですwソフトやプログラムのことが多いかもしれませんが。。。。。

MarkDownをSphinx + Pandocでマニュアル化しよう(その4)

3.各種ツールのコンパイル・インストール

さてここから、本番です。

3.1. Python3のインストール

今回は、Python3をインストールします。 Python2とPython3では、基本的な文法が違うところが多いので、ご注意ください。

参考:Python 2.7.x と 3.x の決定的な違いを例とともに

3.1.1. ソース・コンパイルインストール

ソースからコンパイルインストールします。意外と時間がかかります。

cd /usr/src
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz

tar zxvf Python-3.6.3.tgz
cd /usr/src/Python-3.6.3
./configure CFLAGS=-fPIC --enable-ipv6 --enable-shared --prefix=/usr/local/python
make clean
make
make install

3.1.2. 共有ライブラリとしてリンク

パッケージではないので、共有ライブラリにリンクが紐付いていないので紐付けします。

echo "/usr/local/python/lib" >> /etc/ld.so.conf
ldconfig #再読込

3.1.3. パスの設定

どの環境(ユーザー)からもPythonが使えるようにするため、シェルを仕込みます。

tee /etc/profile.d/python.sh <<-'EOF'
export PATH=/usr/local/python/bin:$PATH
EOF
source /etc/profile

3.1.4. バージョンの確認

起動できるかを確認します。

Pythonのバージョン確認

# python3 -V
> Python 3.6.3

pipのバージョン確認

# pip3 -V
> pip 9.0.1 from /usr/local/python/lib/python3.6/site-packages (python 3.6)

3.2. Pandoc

3.2.1. pandocのインストール

今回は、バイナリファイルを使用します。 ソースからコンパイルすると1時間以上かかるので、今回はバイナリをとってくるのを採用しました。 ただ、ダウンロードしてきたものを確認するために、srcディレクトリに データを一旦保存します。

cd /usr/src
wget https://github.com/jgm/pandoc/releases/download/2.0.1/pandoc-2.0.1-linux.tar.gz
tar xf pandoc-2.0.1-linux.tar.gz
cd /usr/src/pandoc-2.0.1/bin
cp -p pandoc /usr/local/bin/

3.2.2. pandocのバージョン確認

起動できるか確認のため、pandocのバージョンを表示します。

pandoc -v
> pandoc 2.0.1
> Compiled with pandoc-types 1.17.2, texmath 0.9.4.4, skylighting 0.4.2
> Default user data directory: /root/.pandoc
> Copyright (C) 2006-2017 John MacFarlane
> Web:  http://pandoc.org
> This is free software; see the source for copying conditions.
> There is no warranty, not even for merchantability or fitness
> for a particular purpose.

3.3. フォントインストール

Sphinxlatex経由のPDF作成)で使用するフォントをインストールします。

3.3.1. IPAフォントのインストール

このフォントの取り方は非公式です。通常は、ブラウザからダウンロードしてそれをほりこんでください。

cd /usr/src
wget -O IPAfont00303.zip http://ipafont.ipa.go.jp/old/ipafont/IPAfont00303.php
unzip IPAfont00303.zip
mkdir /usr/share/fonts/japanese
mkdir /usr/share/fonts/japanese/TrueType
cp IPAfont00303/*.ttf /usr/share/fonts/japanese/TrueType/
cd /usr/src
wget -O IPAexfont00201.zip http://ymu.dl.osdn.jp/ipafonts/57330/IPAexfont00201.zip
unzip IPAexfont00201.zip
cp IPAexfont00201/*.ttf /usr/share/fonts/japanese/TrueType/

設定を更新

fc-cache -fv

3.3.2. VLGothicフォント

yum -y install vlgothic-fonts
yum -y install vlgothic-p-fonts

3.4. TeX Live

Pdf作成用にTeX Liveを入れます。

※ 注意:ダウンロードやコンパイルを大量にするのでかなり時間がかかります。 2時間近くかかるかもしれないので、覚悟しておいてください。

3.4.1. インストール

3.4.1.1. インストーラーツールの取得

cd /usr/src/
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz

3.4.1.2. インストーラーの実行

解凍する。

tar xzvf install-tl-unx.tar.gz

解凍されたディレクトリにはいり、インストーラーを実行 解凍後のディレクトリ名は、更新がよくあるので変わります。確認してください。

cd /usr/src/install-tl-20171209/
sudo ./install-tl
Loading ftp://ftp.u-aizu.ac.jp/pub/tex/CTAN/systems/texlive/tlnet/tlpkg/texlive.tlpdb
Installing TeX Live 2017 from: ftp://ftp.u-aizu.ac.jp/pub/tex/CTAN/systems/texlive/tlnet (verified)
Platform: x86_64-linux => 'GNU/Linux on x86_64'
Distribution: net  (downloading)
Using URL: ftp://ftp.u-aizu.ac.jp/pub/tex/CTAN/systems/texlive/tlnet
Directory for temporary files: /tmp/3AV3Zold56
======================> TeX Live installation procedure <=====================

======>   Letters/digits in <angle brackets> indicate   <=======
======>   menu items for actions or customizations      <=======

 Detected platform: GNU/Linux on x86_64

 <B> set binary platforms: 1 out of 19

 <S> set installation scheme: scheme-full

 <C> set installation collections:
     40 collections out of 41, disk space required: 5149 MB

 <D> set directories:
   TEXDIR (the main TeX directory):
     /usr/local/texlive/2017
   TEXMFLOCAL (directory for site-wide local files):
     /usr/local/texlive/texmf-local
   TEXMFSYSVAR (directory for variable and automatically generated data):
     /usr/local/texlive/2017/texmf-var
   TEXMFSYSCONFIG (directory for local config):
     /usr/local/texlive/2017/texmf-config
   TEXMFVAR (personal directory for variable and automatically generated data):
     ~/.texlive2017/texmf-var
   TEXMFCONFIG (personal directory for local config):
     ~/.texlive2017/texmf-config
   TEXMFHOME (directory for user-specific files):
     ~/texmf

 <O> options:
   [ ] use letter size instead of A4 by default
   [X] allow execution of restricted list of programs via \write18
   [X] create all format files
   [X] install macro/font doc tree
   [X] install macro/font source tree
   [ ] create symlinks to standard directories

 <V> set up for portable installation

Actions:
 <I> start installation to hard disk
 <P> save installation profile to 'texlive.profile' and exit
 <H> help
 <Q> quit

Enter command: i ← iを入力
Installing to: /usr/local/texlive/2017

3.4.2. パスを全体に通す

どの環境(ユーザー)からもTeX Liveが使えるようにするため、シェルを仕込みます。

tee /etc/profile.d/texlive.sh <<-'EOF'
export PATH="/usr/local/texlive/2017/bin/x86_64-linux:$PATH"
export MANPATH="/usr/local/texlive/2017/texmf-dist/doc/man:$MANPATH"
export INFOPATH="/usr/local/texlive/2017/texmf-dist/doc/info:$INFOPATH"
EOF
source /etc/profile

更新

TeX Liveのツールを念のため更新する

tlmgr update --self
tlmgr update --all

3.5. Sphinx

3.5.1. Sphinxのインストール

ようやくSphinxのインストールにはいります。

pip3 install sphinx

3.5.1. sphinx_rtd_themeのインストール

読みやすいテーマがあるのでダウンロードしておきます。

pip3 install sphinx_rtd_theme

これで、とりあえず、Sphinxを使う環境が整いました。