〜 PyPIデビューまでの道のり 〜
名前: | ごうじん
|
---|---|
所属: | フリーランス |
出身: | 兵庫県 |
Python歴: | 2年 |
お気に入り: | Tornado, PyZMQ |
pip install ..
とか、 easy_install ..
とかしたことあると思いますが、その時に接続しているサーバになります。$ easy_install -U tornado
Searching for tornado
Reading https://pypi.python.org/simple/tornado/
Best match: tornado 4.3
Downloading https://pypi.python.org/packages/source/t/tornado/tornado-4.3.tar.gz#md5=d13a99dc0b60ba69f5f8ec1235e5b232
Processing tornado-4.3.tar.gz
Writing /var/folders/dr/13__6q953t10jkm2vttcbnbh0000gn/T/easy_install-KaS1w2/tornado-4.3/setup.cfg
:
:
Adding tornado 4.3 to easy-install.pth file
Installed /Users/gaujin/osakapy/lib/python2.7/site-packages/tornado-4.3-py2.7-macosx-10.11-intel.egg
Processing dependencies for tornado
Finished processing dependencies for tornado
$ easy_install -U tornado
Searching for tornado
Reading https://pypi.python.org/simple/tornado/
Best match: tornado 4.3
Downloading https://pypi.python.org/packages/source/t/tornado/tornado-4.3.tar.gz#md5=d13a99dc0b60ba69f5f8ec1235e5b232
Processing tornado-4.3.tar.gz
Writing /var/folders/dr/13__6q953t10jkm2vttcbnbh0000gn/T/easy_install-KaS1w2/tornado-4.3/setup.cfg
:
:
Adding tornado 4.3 to easy-install.pth file
Installed /Users/gaujin/osakapy/lib/python2.7/site-packages/tornado-4.3-py2.7-macosx-10.11-intel.egg
Processing dependencies for tornado
Finished processing dependencies for tornado
@gaujin_jp
こんにちはー
こちらのcrontabネタ、今度のPyCon JP の発表(野球)で引用したいのですが、よろしいでしょうか?Imageはこんな感じです!
pic.twitter.com/x0f3GjpnHA
— Shinichi Nakagawa (@shinyorke) 2015, 10月 4
予行演習用PyPI
PyDevは、ドットで始まるリソースファイルは、デフォルト表示されないので、フィルタを変更しておく。
ドット以外のファイルもお好みで設定してください。
ビルド結果をログで確認できる。
ブランチとタグのビルド結果を、メール通知してくれる。
ビルド結果のバッジでさりげなくアピール。
@gaujin_jp
タグはコミットに対して付くので、そのコミットがスキップするように書かれている場合にはビルドは起りません。
— Travis CI (@travisci)
2015, 11月 23
“TESTING SITE”ラベルが目印
アカウントの登録申請をする
入力内容の確認をする
メールに添付されたリンクをクリックする
アカウント登録完了
$ cat <<EOF > ~/.pypirc
[distutils]
index-servers =
testpypi
[testpypi]
repository: https://testpypi.python.org/pypi
username: ユーザ名
password: パスワード
EOF
.pypircファイルを用意する
$ git clone https://github.com/gaujin/tornado-crontab.git
Cloning into 'tornado-crontab'...
remote: Counting objects: 114, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 114 (delta 0), reused 0 (delta 0), pack-reused 108
Receiving objects: 100% (114/114), 14.57 KiB | 0 bytes/s, done.
Resolving deltas: 100% (51/51), done.
Checking connectivity... done.
登録したいソースコードをクローンする
$ git checkout refs/tags/v0.2
Note: checking out 'refs/tags/v0.2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 50dc188... deleted Framework classifier
testpypiに登録するタグに切り替える
$ python setup.py register -vnr testpypi
running register
running egg_info
writing requirements to tornado_crontab.egg-info/requires.txt
writing tornado_crontab.egg-info/PKG-INFO
writing top-level names to tornado_crontab.egg-info/top_level.txt
writing dependency_links to tornado_crontab.egg-info/dependency_links.txt
reading manifest file 'tornado_crontab.egg-info/SOURCES.txt'
writing manifest file 'tornado_crontab.egg-info/SOURCES.txt'
running check
Registering tornado-crontab to https://testpypi.python.org/pypi
Server response (200): OK
testpypiにパッケージを登録する
$ python setup.py sdist upload -r testpypi
running sdist
running egg_info
writing requirements to tornado_crontab.egg-info/requires.txt
writing tornado_crontab.egg-info/PKG-INFO
writing top-level names to tornado_crontab.egg-info/top_level.txt
writing dependency_links to tornado_crontab.egg-info/dependency_links.txt
reading manifest file 'tornado_crontab.egg-info/SOURCES.txt'
writing manifest file 'tornado_crontab.egg-info/SOURCES.txt'
running check
creating tornado-crontab-0.2
creating tornado-crontab-0.2/tornado_crontab
creating tornado-crontab-0.2/tornado_crontab.egg-info
:
:
Creating tar archive
removing 'tornado-crontab-0.2' (and everything under it)
running upload
Submitting dist/tornado-crontab-0.2.tar.gz to https://testpypi.python.org/pypi
Server response (200): OK
testpypiにパッケージをアップロードする
なっ...なんじゃこれは...
with codecs.open(os.path.join(here, "README.rst"), encoding="utf8") as f:
long_description = f.read()
setup(
:
:
description=long_description,
:
:
)
説明に長い方を入れていたからですね。
綺麗に表示されました。これで予行演習は終わりですね。
アカウントの登録申請をする
入力内容の確認をする
メールに添付されたリンクをクリックする
アカウント登録完了
$ vi ~/.pypirc
$ cat ~/.pypirc
[distutils]
index-servers =
pypi
testpypi
[pypi]
repository: https://pypi.python.org/pypi
username: ユーザ名
password: パスワード
[testpypi]
repository: https://testpypi.python.org/pypi
username: ユーザ名
password: パスワード
.pypircファイルにPyPIの情報を追加します。
$ git clone https://github.com/gaujin/tornado-crontab.git
Cloning into 'tornado-crontab'...
remote: Counting objects: 114, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 114 (delta 0), reused 0 (delta 0), pack-reused 108
Receiving objects: 100% (114/114), 14.57 KiB | 0 bytes/s, done.
Resolving deltas: 100% (51/51), done.
Checking connectivity... done.
登録したいソースコードをクローンする
$ git checkout refs/tags/v0.2
Note: checking out 'refs/tags/v0.2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 50dc188... deleted Framework classifier
pypiに登録するタグに切り替える
$ python setup.py register -vnr pypi
running register
running egg_info
writing requirements to tornado_crontab.egg-info/requires.txt
writing tornado_crontab.egg-info/PKG-INFO
writing top-level names to tornado_crontab.egg-info/top_level.txt
writing dependency_links to tornado_crontab.egg-info/dependency_links.txt
reading manifest file 'tornado_crontab.egg-info/SOURCES.txt'
writing manifest file 'tornado_crontab.egg-info/SOURCES.txt'
running check
Registering tornado-crontab to https://pypi.python.org/pypi
Server response (200): OK
pypiにパッケージを登録する
$ python setup.py sdist upload -r pypi
running sdist
running egg_info
writing requirements to tornado_crontab.egg-info/requires.txt
writing tornado_crontab.egg-info/PKG-INFO
writing top-level names to tornado_crontab.egg-info/top_level.txt
writing dependency_links to tornado_crontab.egg-info/dependency_links.txt
reading manifest file 'tornado_crontab.egg-info/SOURCES.txt'
writing manifest file 'tornado_crontab.egg-info/SOURCES.txt'
running check
creating tornado-crontab-0.2
creating tornado-crontab-0.2/tornado_crontab
creating tornado-crontab-0.2/tornado_crontab.egg-info
:
:
Creating tar archive
removing 'tornado-crontab-0.2' (and everything under it)
running upload
Submitting dist/tornado-crontab-0.2.tar.gz to https://pypi.python.org/pypi
Server response (200): OK
pypiにパッケージをアップロードする
from __future__ import print_function
def hello_crontab(value):
print("Hello, {}".format(value))
if __name__ == "__main__":
hello_crontab("crontab")
* * * * * /path/to/this.py > /tmp/this.log 2>&1
$ easy_install tornado-crontab
from __future__ import print_function
import tornado.ioloop
from tornado_crontab import crontab
@crontab("* * * * *")
def hello_crontab(value):
print("Hello, {}".format(value))
if __name__ == "__main__":
hello_crontab("crontab")
tornado.ioloop.IOLoop.instance().start()
/path/to/this.py > /tmp/this.log 2>&1 &