3
3

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.

VSCode+PyInstallerで実行ファイル名に自動でバージョンを付ける

Last updated at Posted at 2019-01-04

VSCodeのカスタムタスクを用いて、PyInstallerで実行ファイルを作るときにバージョンを含んだファイル名を自動でつける。
git tagからverを生成します。(git describe)

カスタムタスクの非公式ドキュメント

Windowsでの環境ごとのpath指定があまりきれいではありません。Anaconda+conda環境が前提なので、そのほか環境ではうまく動かないかもしれません。

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run Pyinstaller",
            "type": "shell",
            "command": "./script/pyinstaller.sh",
            "windows": {
                "command": ".\\script\\pyinstaller.cmd ${config:python.pythonPath}"
            },
            "group": "build",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            }
        }
    ]
}
script/pyinstaller.sh
# !/bin/sh

ver=`git describe --tags`
set -x
pyinstaller --onefile -n EXENAME_$ver main.py
script/pyinstaller.cmd
@for /f "usebackq tokens=*" %%i in (`git describe --tags`) do @set VER=%%i
%1\..\Scripts\pyinstaller --onefile -n EXENAME_%VER% main.py
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?