venv(Python仮想環境)を構築するスクリプト。
近年、Pythonのパッケージ管理ライブラリには poetry や pyflow などがあるが、それらはまだ発展途上に感じる。 その背景を踏まえ、個人的に venv + requirements.txt をしばらく使いたかったので make_venv を作成した。
-
Python3 を導入する
-
make_venv.sh をダウンロードし、Pythonプロジェクトディレクトリへ格納
wget https://raw.githubusercontent.com/gsuke/make-venv/main/make_venv.sh
-
(必要に応じてSettingsを変更)
-
requirements.txt を作成し、必要なライブラリを入力
-
./make_venv.shを実行
-
以下の実行環境を導入する
-
PowerShell (7.2~)
-
https://www.microsoft.com/ja-jp/p/powershell/9mz1snwt0n5d よりインストールする
-
Powershellの初回起動時は以下のコマンドを叩き、実行ポリシーを変更する。
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
-
-
make_venv.ps1 をダウンロードし、Pythonプロジェクトディレクトリへ格納
Invoke-WebRequest https://raw.githubusercontent.com/gsuke/make-venv/main/make_venv.ps1 -OutFile make_venv.ps1
-
(必要に応じてSettingsを変更)
-
requirements.txt を作成し、必要なライブラリを入力
-
PowerShellで
.\make_venv.ps1を実行
以下の環境で動作確認済み。
-
Windows 10
-
Debian 11 (docker-compose.yml 参照)