This post documents a reproducible setup for developing a Python project inside WSL using VS Code,
with a dedicated Conda environment, unittest discovery, and convenient VSCode Tasks / Debug configs.
This setup is for developing drafts-checker.py - Stage-Based Preparation Tool for Publishing Recipes
.vscode/ is.vscode/ is a project-local configuration folder for Visual Studio Code.
Files here apply only to the current repository/workspace (not global machine settings).
It’s the place to store reproducible editor/run/debug/test settings for the project.
.vscode/.vscode/settings.json: Workspace settings (interpreter, test discovery, env files, terminal behavior).vscode/launch.json: Debug configurations (what runs when you press F5).vscode/tasks.json: Reusable command shortcuts (Tasks: Run Task) such as tests, checkers, docker compose/home/<user>/miniconda3/...)In VS Code:
Then open the project as a WSL workspace (not Windows paths).
From a WSL terminal:
cd ~/src/family_recipes
code .
This ensures VS Code runs the workspace in the WSL context (so it can see Linux interpreters and Linux conda envs).
Inside WSL:
conda create -n family_recipes python=3.12 -y
conda activate family_recipes
which python
python -c "import sys; print(sys.executable)"
Expected:
which python and sys.executable point to:
/home/<user>/miniconda3/envs/family_recipes/bin/pythonSome dependencies are best installed via conda, while others are typically installed via pip.
conda activate family_recipes
conda install -y click pyyaml
python -c "import click, yaml; print('ok')"
conda activate family_recipes
python -m pip install -U pip
pip install openai python-dotenv
python -c "import openai; from dotenv import load_dotenv; print('ok')"
From the repo root:
python -m unittest discover -s code/_Tests -p "test_*.py" -v
Create a repo-level .env file (used by VS Code Python tooling):
<repo>/.env
PYTHONPATH=code
Create:
<repo>/.vscode/settings.json
{
"python.defaultInterpreterPath": "/home/sagivba-adm/miniconda3/envs/family_recipes/bin/python",
"python.testing.unittestEnabled": true,
"python.testing.pytestEnabled": false,
"python.testing.unittestArgs": [ "-v", "-s", "code/_Tests", "-p", "test_*.py" ],
"python.envFile": "${workspaceFolder}/.env",
"python.terminal.activateEnvironment": true
}
Notes:
{...}{...} blocks).Developer: Reload Window.Create:
<repo>/.vscode/launch.json (example)
{
"version": "0.2.0",
"configurations": [
{
"name": "unittest: all (discover)",
"type": "python",
"request": "launch",
"module": "unittest",
"args": ["discover", "-s", "code/_Tests", "-p", "test_*.py", "-v"],
"console": "integratedTerminal",
"justMyCode": true,
"envFile": "${workspaceFolder}/.env"
}
]
}
Maintain:
<repo>/.vscode/tasks.json
Key points:
${command:python.interpreterPath} so Tasks always run with the interpreter selected in VS Code (your conda env).unittest discoverdrafts-checker.py (with and without --use-ai)--use-ai mode)To run the pipeline with AI features, export your key:
export OPENAI_API_KEY="YOUR_KEY_HERE"
Persist it (one common approach) by adding to ~/.bashrc:
echo 'export OPENAI_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
Verify:
echo "$OPENAI_API_KEY" | head -c 8; echo
Inside VS Code terminal:
conda activate family_recipes
which python
python -c "import sys; print(sys.executable)"
python -m unittest discover -s code/_Tests -p "test_*.py" -v
Expected: