2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

twineからパッケージをより安全にアップロードする

Last updated at Posted at 2019-09-04

最近になってPyPIが2段階認証だったりトークン機能が対応したようで、twineからより安全にパッケージをアップロードすることができました。

日本語記事が少ないと思うので忘備録を兼ねて書いておきます。

※投稿現在はベータ機能としてリリースされているようなので、もしかしたら変わってるかもしれません。

トークンを発行する

https://pypi.org/manage/account/token/ にアクセスしてトークンの発行ページにアクセスします。
ログインしていない場合はログイン画面が出るはずです。

image.png

Token nameには任意の名前を入力します。これはAPIトークンの管理をするときに表示されるものです。

Scopeには対象のパッケージを選択します。
image.png

トークンが発行されると以下の項目が表示されます。このトークンを控えてください。
1度しか表示されないためご注意ください。

image.png

設定をする

ホームディレクトリにアクセスし、.pypircという名前でファイルを作成します。

.pypircに関する詳しい設定は割愛いたします

.pypirc
[distutils]
index-servers =
  pypi

[pypi]
username: __token__
password: pypi-********

username必ず__token__と入力してください。

passwordには先程控えたトークンを貼り付けます。

これで設定は完了です。twineコマンドでアップロードなどをして正常にアップロードできるか試してみてください。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?