Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize python setup, ensure homu gets python3 #148

Merged
merged 3 commits into from Feb 11, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Install python, pip, virtualenv on OS X

  • Loading branch information
aneeshusa committed Feb 11, 2016
commit b4e4b521a3c93339e28dc0032aa4101f6673384b
@@ -1,39 +1,34 @@
{% from tpldir ~ '/map.jinja' import config with context %}
{% if grains['kernel'] != 'Darwin' %}
# Ubuntu has python2 as default python
python2:
pkg.installed:
- pkgs:
- python
- python-dev
python3:
{% if grains['os'] == 'Ubuntu' %}
python2-dev:
pkg.installed:
- pkgs:
- python3
- python-dev
{% endif %}
# Ensure pip is default by purging pip3
pip:
pkg.installed:
- pkgs:
{% if grains['os'] == 'Ubuntu' %}
- python-pip
{% elif grains['os'] == 'MacOS' %}
- python # pip is included with python in homebrew
{% endif %}
- reload_modules: True
pip3:
pkg.purged:
- pkgs:
- python3-pip
# Virtualenv package creates virtualenv and virtualenv-3.4 executables

This comment has been minimized.

Copy link
@Manishearth

Manishearth Nov 4, 2015

Member

In my experience I needed to pip3 install virtualenv before I got virtualenv3. Should we make two keys here, one with bin_env: pip and one with bin_env: pip3?

This comment has been minimized.

Copy link
@aneeshusa

aneeshusa Nov 4, 2015

Author Member

I just tested this in a fresh vagrant box. It started out without pip or virtualenv (any version). I ran

  1. sudo apt-get install python-pip
  2. sudo pip install virtualenv
    This created /usr/local/bin/virtualenv and /usr/local/bin/virtualenv-3.4 executables, the latter of which works fine for the homu venv - I peeked inside the vagrant box and the homu venv had python3 and pip3.

bin_env is used when you want to run pip inside a virtualenv, such as in homu/init.sls, so I'm not sure what you are proposing with the two keys. Could you please clarify?

This comment has been minimized.

Copy link
@Manishearth

Manishearth Nov 4, 2015

Member

Are the default python/pip/virtualenv the 2.7 ones?

bin_env is for both selecting a virtualenv or selecting a custom binary to run. It lets you say "Install this pip package, but use the pip3.4 binary". https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.pip.html

This comment has been minimized.

Copy link
@aneeshusa

aneeshusa Nov 4, 2015

Author Member

Yes, on Ubuntu the defaults are all 2.7. Ubuntu is not planning to change this until PEP 394 says otherwise.

bin_env: Right, I'm using this but in a different way. The approach I'm taking is to use virtualenv.managed and pass in python3 in homu/init.sls; salt automatically will install pip3 in the virtualenv (pip3 is bundled with python starting with python3.4). Then, I use pip.installed and set bin_env to the virtualenv location for homu's dependencies, which means it ends up using pip3 under the hood.

Also, for future reference you'll want to use the state documentation, not the module docs :)

This comment has been minimized.

Copy link
@Manishearth

Manishearth Nov 4, 2015

Member

Okay, sounds good. So when you say python: python3 in the homu setup below, does that mean that it will also use virtualenv3? Because homu doesn't even install properly with an older virtualenv version, it needs to use pip3, python3, and virtualenv3. (Not sure if virtualenv2 even lets you create a python3 env, but it's good to be certain)

virtualenv:
pip.installed:
- pkgs:
- virtualenv
- require:
- pkg: pip
- pkg: pip3
{% endif %}
servo:
user.present:
@@ -1,3 +1,8 @@
python3:
pkg.installed:
- pkgs:
- python3

homu:
git.latest:
- name: https://github.com/servo/homu
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.