Add helpful Python dependencies to the current uv project.
- package_dir: The directory path where the Python package's
pyproject.tomlfile is located
-
If
package_diris not provided, check for apyproject.tomlfile in the current directory. If nopyproject.tomlis found, ask the user: "What is the package directory location?" -
Navigate to the package directory (use current directory if
pyproject.tomlexists there, otherwise use the provided or asked-for directory) -
Add regular dependencies:
python-dotenv- For loading environment variables from .env filespython-decouple- For managing settings and configuration
-
Add development dependencies:
black- Code formatterpre-commit- Git hooks frameworkpylint- Linter for Python codeperflint- Performance linterruff- Fast Python linter and formatterbandit- Security linter for Pythonpytest- Testing frameworkdetect-secrets- Tool to detect secrets in code
Run these commands in the package directory (where pyproject.toml exists):
uv add python-dotenv python-decoupleuv add --group dev black pre-commit pylint perflint ruff bandit pytest detect-secretsWith parameter:
- package_dir:
tools/python/my_package - This will navigate to
tools/python/my_package/and run the uv add commands there
Without parameter:
- Check current directory for
pyproject.toml - If found, use current directory
- If not found, prompt user for package directory location
- Then proceed with adding dependencies
- The package directory must contain a
pyproject.tomlfile - The directory location can be absolute or relative to the workspace root
- The dev dependencies will be added to the
[dependency-groups]dev section inpyproject.toml - Regular dependencies will be added to the
[project]dependencies section