Skip to content

Instantly share code, notes, and snippets.

@1st
Last active March 21, 2020 01:16
Show Gist options
  • Save 1st/4d8f2bd920cd047ccf1e to your computer and use it in GitHub Desktop.
Save 1st/4d8f2bd920cd047ccf1e to your computer and use it in GitHub Desktop.
My settings for Python dev env for macOS (file: ~/.bash_profile or ~/.zshrc)
#
# My settings for python dev env on MacBook.
# I use HomeBrew to install python and python3
# cat ~/.profile
#
# load all completions
source /usr/local/etc/bash_completion.d/*
# Python VirtualEnv
export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
# python: resolve problem with install MySQL-python
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
# MySQL
homebrew=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin
export PATH=$homebrew:$PATH
# Django
#source ~/.django_completion
#export LC_CTYPE=ru_RU.UTF-8
#export LANG=ru_RU.UTF-8
# Aliases (shortcuts)
alias rm_pyc="find . -type f -name '*.pyc' -exec rm {} \;"
alias rm_orig="find . -type f -name '*.orig' -exec rm {} \;"
alias find_pyc="find . -type f -name '*.pyc'"
alias celeryd='./manage.py celeryd --loglevel=debug --verbosity=2'
alias celerybeat='./manage.py celerybeat --verbosity=2 --loglevel=DEBUG'
alias mkvirtualenv3='mkvirtualenv --python=$(which python3)'
# Fix broken virtual env after python version upgrade
function fix_virtualenv {
#
# Usage: fix_virtualenv project_name
#
PROJECT_NAME=$1
# First of all, delete all broken links
find ~/.virtualenvs/$PROJECT_NAME/ -type l -delete
# Then create new links to the current Python version
virtualenv ~/.virtualenvs/$PROJECT_NAME/
}
@1st
Copy link
Author

1st commented Mar 21, 2020

You can find other useful information about work with Python on macOS here: https://github.com/1st/python-on-osx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment