Last active
April 23, 2025 12:32
-
-
Save agconti/1ed26b8f9957b21b00439028300c3394 to your computer and use it in GitHub Desktop.
An direnv setup for easily managing local python development environments. Put the .envrc at the root of your repo and the two other files in a tools directory. Manage creds via an .env file directing to 1password secrets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layout python3 | |
# Automatically install dependencies when requirements.txt changes | |
LAST_INSTALLED_DEPENDENCIES_FLAG="$VIRTUAL_ENV/.dependencies_installed" | |
echo $LAST_INSTALLED_DEPENDENCIES_FLAG | |
if [ ! -f $LAST_INSTALLED_DEPENDENCIES_FLAG ] || [ requirements.txt -nt $LAST_INSTALLED_DEPENDENCIES_FLAG ]; then | |
echo "Installing dependencies..." | |
pip install -r requirements.txt | |
touch $LAST_INSTALLED_DEPENDENCIES_FLAG | |
fi | |
PATH_add "./tools" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
echo "๐ Formatting and linting codebase..." | |
echo "๐ Formatting code with Black..." | |
black . | |
echo "๐ Sorting imports with isort..." | |
isort . | |
echo "๐ฎโโ๏ธ Running pylint..." | |
pylint --ignore $VIRTUAL_ENV --recursive=y --exit-zero . | |
echo "๐ Running type checking..." | |
mypy . | |
echo "โ Formatting and linting complete!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Check if a command was provided. | |
if [ $# -eq 0 ]; then | |
echo "Error: No command provided" | |
echo "Usage: op_run.sh <command> [args...]" | |
exit 1 | |
fi | |
# log in to 1password if signed out. | |
op whoami || eval $(op signin) | |
# Execute the command using op run | |
echo "๐ Running command with 1Password environment variables..." | |
echo "op run --env-file="./.env" -- $@" | |
op run --env-file="./.env" -- "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment