【python】venvを用いたgit管理について
開発環境
- WSL2 (Windows10でも可能)
- python 3.8
手順
プロジェクト作成
- venv (https://docs.python.org/ja/3/library/venv.html) を使用
- Windows10の場合には適宜コマンドを変更する。
$ python -m venv ~/path_to_your_project_folder $ cd ${YOUR_PROJECT_FOLDER} $ git init $ touch .gitignore
- この時点で
.gitignore
に記述をする。基本的には https://github.com/github/gitignore/blob/main/Global/VirtualEnv.gitignore に倣えばよい。
/bin /include /lib /lib64 /share pyvenv.cfg
レポジトリからの環境構築
$ git clone https://from_your_repository_url $ cd ${YOUR_PROJECT_FOLDER} $ python -m venv . # WSL2 $ source bin/activate # Windows PowerShell $ Scripts\Activate.ps1 $ pip install -r requirement.txt # 環境終了 (仮想環境内にて) $ deactivate