この記事は、中学生から大学生(専門前)までを対象に書いています。
基本的に習うより慣れろなので、コピペして、差分だけ書くようにしています。
こちらの記事を参考にさせてもらいました。
というかそのままです。
PyPIパッケージ公開手順
https://qiita.com/shinichi-takii/items/e90dcf7550ef13b047b5
こちらも参考にしています。
https://qiita.com/Kensuke-Mitsuzawa/items/7717f823df5a30c27077
まず、サンプルプロジェクトをダウンロードします。
名前はchokozainerrlにしました。
.gitとrequirement.txtを削除します。
githubに、chokozainerrlリポジトリを作成します。
githubへの登録は、こちらを参考にしました。
https://qiita.com/under_chilchil/items/ec9d0050c1e3fb6576de
これくらいの英語には慣れましょう。
cd chokozainerrl
git init
git add .
git commit -m 'first commit'
git remote add origin https://github/chokozainer/chokozainerrl.git
git push -u origin master
以降は、VSCodeで編集します。
setpu.pyは、以下のようにしました。
# -*- coding: utf-8 -*-
import os, sys
from setuptools import setup, find_packages
def read_requirements():
"""Parse requirements from requirements.txt."""
reqs_path = os.path.join('.', 'requirements.txt')
with open(reqs_path, 'r') as f:
requirements = [line.rstrip() for line in f]
return requirements
with open('README.md', encoding='utf-8') as f:
readme = f.read()
with open('LICENSE') as f:
license = f.read()
setup(
name='chokozainerrl',
version='0.0.7',
description='Wrapper package for chainerRL',
long_description=readme,
long_description_content_type='text/markdown',
author='chokozainer',
author_email='fgtohru@gmail.com',
install_requires=read_requirements(),
url='https://github.com/chokozainer/chokozainerrl',
license=license,
packages=find_packages(exclude=('tests', 'docs','sample'))
)
テストコードは、、、。
そもそも、colaboratory notebookを活用する場合、コンソールベースでは使いづらいので、その部分をwrapperするのがchokozainerRLなので、どうやってテストを書くのか? 微妙すぎる話題。見つかったら書く予定。
アップロードの準備をします。
まずは、インストール。
pip install wheel twine
とりあえず作ってみます。
python setup.py bdist_wheel sdist
distフォルダに2つのファイルができました。
testPypiにアップロードします。
twine upload --repository testpypi dist/*
notebookの方は、
!pip --no-cache-dir install --upgrade --index-url https://test.pypi.org/simple/ chokozainerrl
rwquirements.txtに、chainerrlを入れておいたので、かなり楽になりました。
いろいろとトラップに引っかかっているので、chokozainerRLはしばらくtestバージョンで使用します。