donnemartin / dev-setup

macOS development environment setup: Easy-to-understand instructions with automated setup scripts for developer tools like Vim, Sublime Text, Bash, iTerm, Python data analysis, Spark, Hadoop MapReduce, AWS, Heroku, JavaScript web development, Android development, common data stores, and dev-based OS X defaults.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyenv over homebrew python

AlJohri opened this issue · comments

Given that you're using rbenv, I was wondering why you're not using pyenv? I've found it to be invaluable especially working back and forth between python 2 and 3 pretty extensively. After all, we should all be starting new projects in python 3, right?

The source code is well maintained and nearly identical to rbenv. The rbenv HEAD is even merged in periodically.

The installation is entirely identical with the exception that python-build (like ruby-build) is included in the pyenv package :)

brew install pyenv
brew install pyenv-virtualenvwrapper # not necessary, but a nicety
pyenv install -l # list python versions
pyenv install 2.7.10
pyenv install 3.5.0
pyenv global 2.7.10 3.5.0 # sets global python2 and python3

Please let me know if you'd like me to submit a PR!

P.S. Love the repository, I've been trying to maintain a similar repo: https://github.com/AlJohri/dotfiles/blob/gh-pages/Brewfile
You should consider using the brew bundle command instead of brew.sh. (its pretty new, released within the last year).

I do actually use pyenv regularly :)

I haven't had a chance to update the repo yet. Awhile ago I had started collecting preliminary commands to install pyenv but it probably needs tweaks/polishing.

###############################################################################
# Pyenv                                                                       #
###############################################################################

echo "------------------------------"
echo "Setting up pyenv."

# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
  echo "Installing homebrew..."
  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

# Install pyenv
brew update
brew install pyenv

EXTRA_PATH=~/.extra
echo $EXTRA_PATH
echo '' >> $EXTRA_PATH
echo '' >> $EXTRA_PATH
echo '# Pyenv, added by pydata.sh' >> $EXTRA_PATH
echo 'eval "$(pyenv init -)"' >> $EXTRA_PATH
echo 'eval "$(pyenv virtualenv-init -)"' >> $EXTRA_PATH
echo '' >> $EXTRA_PATH
source $EXTRA_PATH

pyenv install 3.3.6
pyenv install 3.4.3
pyenv install 3.5.0
pyenv global 3.4.3

# If you encounter: ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
# You may need to tell the compiler where the openssl package is located:
# CFLAGS="-I$(brew --prefix openssl)/include" \
# LDFLAGS="-L$(brew --prefix openssl)/lib" \
# pyenv install -v 3.4.3

# Remove outdated versions from the cellar.
brew cleanup

# Restart the shell to enable pyenv-virtualenv
exec "$SHELL"

Please let me know if you'd like me to submit a PR!

Sure, we might need to merge our commands together.

You should consider using the brew bundle command instead of brew.sh. (its pretty new, released within the last year).

Thanks for the tip, I'll check it out!