shigeyukioba / matchernet

Apache License 2.0
1 stars 1 forks source link

テスト公開 #27

Open uchihashikenshi opened 4 years ago

uchihashikenshi commented 4 years ago

目的

PyPI にテストでパッケージ公開を行う

提案内容

タスク

関連

uchihashikenshi commented 4 years ago

https://test.pypi.org/project/matchernet-py-001/0.1/ こちらでテスト公開。 requirements.txt の修正などはまだ。

uchihashikenshi commented 4 years ago

再アップロード手順。

$ rm -f -r matchernet_py_001.egg-info/* dist/*
$ python setup.py sdist bdist_wheel
$ twine upload --repository testpypi dist/*
uchihashikenshi commented 4 years ago

ドキュメントの公開手順。 まず、/docs にAPIドキュメント用の Sphinx プロジェクトを作成する。

$ sphinx-apidoc -F -o docs/ matchernet_py_001/
$ ls docs/
Makefile              conf.py
_build                index.rst
_static               make.bat
_templates            matchernet_py_001.rst

Makefile ができているので、make を実行することでドキュメントが自動生成される。

$ cd docs
$ make html

docs/_build/html 配下に、HTML ファイルができている。

$ ls html/
_modules               matchernet_py_001.html
_sources               objects.inv
_static                py-modindex.html
genindex.html          search.html
index.html             searchindex.js
uchihashikenshi commented 4 years ago

テスト公開されたことで、pip install したものを使うようになりますが、こちらを利用するとバージョンが上がるまで開発状況が反映されなくなります。 手元で修正・新規開発したもの、あるいは最新のブランチを使用したい場合は、以下のようにして手元のライブラリの優先順位を上げてください。

import sys
import os
sys.path.insert(1, os.getcwd())
# ライブラリを検索する際、現在のディレクトリが実行ファイルパスの次に優先順位が高くなる
uchihashikenshi commented 4 years ago

docs/ 以下をドキュメントとして公開する方針にした。 その際、conf.pyextensions を2つ追加。

'sphinx.ext.githubpages',
'sphinx.ext.mathjax'

sphinx.ext.githubpages によって .nojekyll が生成され、css が反映されるようになる。

uchihashikenshi commented 4 years ago

ドキュメントの公開手順を更新。

まず、/docs にAPIドキュメント用の Sphinx プロジェクトを作成する。

$ sphinx-apidoc -F -o docs/ matchernet_py_001/
$ ls docs/
Makefile              conf.py
_build                index.rst
_static               make.bat
_templates            matchernet_py_001.rst

Makefile ができているので、make を実行することでドキュメントが自動生成される。

$ cd docs
$ make html

docs/_build/html 配下に、HTML ファイルができている。

$ ls html/
_modules               matchernet_py_001.html
_sources               objects.inv
_static                py-modindex.html
genindex.html          search.html
index.html             searchindex.js

ドキュメントとして公開されるのは docs/ 以下であるため、docs/_build/html のファイルをdocs 以下に持ってくる必要がある。

# pwd: docs
$ cp -pr _build/html/* ./
$ cp -pr _build/html/.nojekyll ./

隠しファイルはデフォルトでコピーできないので、別途 .nojekyll のコピーも行っている。 以上を行ったあと、add & commit & push でドキュメントが更新される。

uchihashikenshi commented 4 years ago

pypi のパッケージページの readme に画像を反映させるには外部リンクの取得が必要。 https://stackoverflow.com/questions/41983209/how-do-i-add-images-to-a-pypi-readme-that-works-on-github/46875147