1
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.

PyPIへのアップロード&パッケージ化を行うPowerShellスクリプトを書いた

Posted at

ライブラリのアップロードはそう頻繁にあることじゃなく、ついつい手順を忘れてしまうのでスクリプトを書きました。
いちおうアップロードの直前に「本当にアップロードしても良いか?」聞くおまけ付きです。

いちおう全文英語なのでOSSのリポジトリとかにうっかり入れても安心。

upload.ps1
Remove-Item "*.egg-info" -Recurse
Remove-Item "dist" -Recurse
Remove-Item "build" -Recurse
python setup.py sdist
python setup.py bdist_wheel
$title = "PyPI upload?"
$message = "The package was created in the `dist` folder. Can I continue uploading to PyPI?"
$tChoiceDescription = "System.Management.Automation.Host.ChoiceDescription"
$options = @(
    New-Object $tChoiceDescription ("Yes(&Y)", "Upload the library to PyPI.")
    New-Object $tChoiceDescription ("No(&N)", "Cancel the upload. The library remains in the `dist` folder.")
)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
    0 {
      twine upload dist/*
      break
    }
    1 {
      "Cancel the upload. The library remains in the `dist` folder."
      break
    }
}

なお、アップロードに必要なsdistwheeltwineコマンドは事前にインストール済み、PyPIアカウントの情報は.pypircに記入済みであるものとします(この辺の処理がまだの人は参考記事を読んでください)。

参考記事

1
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
1
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?