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

Conversation

@aneeshusa
Copy link
Member

aneeshusa commented Nov 4, 2015

  • Trusty comes with python3, pip and virtualenv by default, but write
    states defensively to install these dependencies as required and require
    the pip or virtualenv states as used by other states.
  • Homu requires a python3 toolchain, use virtualenv-3.4 and pass python:
    python3 to get the correct setup (including pip3 inside the venv).
  • Update the style guide example to use pkg.installed instead of
    pip.installed to avoid muddling it with a require: pip.

Fixes #142.

Review on Reviewable

- pkgs:
- python3-pip
# Virtualenv package creates virtualenv and virtualenv-3.4 executables

This comment has been minimized.

@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.

@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.

@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.

@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.

@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)

@aneeshusa aneeshusa force-pushed the aneeshusa:ensure-python3-venv-for-homu branch from 9295f2a to 929a16d Nov 4, 2015
@Manishearth
Copy link
Member

Manishearth commented Nov 4, 2015

r? @larsbergstrom @edunham

I don't have the salt-fu to be completely sure of what's going on here 😄

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 4, 2015

If the salt states aren't clear, let me know what's confusing! These should be relatively easy to read as high-level declarative descriptions.

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 4, 2015

Also, I don't know anything about how installing python, pip, and virtualenv works on OS X (versions 2 and 3). Are they installed by default or can/should they be installed via homebrew? I don't have a Mac so I'd appreciate some help figuring that out to address the build failures.

@Manishearth
Copy link
Member

Manishearth commented Nov 4, 2015

We need pip3 only on servo-master

@Manishearth
Copy link
Member

Manishearth commented Nov 4, 2015

(which is linux)

@Manishearth
Copy link
Member

Manishearth commented Nov 4, 2015

Overall LGTM, but I'd like someone who understands salt more than I do (which is nearly nothing) to look at it too.

Also, we might want to test this out from scratch on a prod instance. At the very least we should backup the homu dir, delete the original, and ensure it's created from scratch correctly.

(A related issue is that servo-master is never spun up from scratch unlike the other machines, so the salt config may not reflect the actual steps needed for servo-master to be set up -- like python3 being missing from salt. We discussed this the other day and might be testing this somehow soon)

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 4, 2015

If we only need python3 on linux then I'm probably going to change how I do this a bit.

What base image are you using for prod? I can probably modify the Vagrant boxes to use that instead so you can test it locally. (It works fine AFAICT with the ubuntu/trusty64 boxes).

- venv_bin: virtualenv-3.4
- python: python3

This comment has been minimized.

@aneeshusa

aneeshusa Nov 4, 2015

Author Member

@Manishearth the venv_bin option is what tells salt to use virtualenv-3.4, and the python option tells virtualenv to install python3 (and pip3) inside the virtualenv.

This comment has been minimized.

@Manishearth

Manishearth Nov 4, 2015

Member

Oh, right, I didn't notice that, sorry 😄

@Manishearth
Copy link
Member

Manishearth commented Nov 4, 2015

I'm okay with python3 being available on mac too as long as buildbot doesn't break.

System is trusty:

root@servo-master:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty
@edunham
Copy link
Contributor

edunham commented Nov 4, 2015

Reviewed 7 of 7 files at r1.
Review status: 5 of 7 files reviewed at latest revision, 3 unresolved discussions.


common/init.sls, line 14 [r1] (raw file):
I'm surprised that everything installs successfully without python3-dev here, but if you've tested it in a VM and it works, we should be good to go.


Comments from the review on Reviewable.io

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 5, 2015

Testing in the servo-master Vagrant VM, the provisioning succeeds without errors, and homu successfully starts up. (If you ssh in, service homu status says homu is dead, but sudo less +F /var/log/upstart/homu.log reveals that it dies very quickly because the fake github credentials are no good.) You may want to do some testing of your own but it looks like python3-dev is not needed.

@Manishearth
Copy link
Member

Manishearth commented Nov 5, 2015

Yeah, homu should fail early if the venv is not set up correctly -- if the virtualenv is the wrong version the egg doesn't even unpack correctly, and if you hack it so that it does, the Python parser will choke on the * parameters. If it's getting to the ping-github stage everything should be good.

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 5, 2015

Also note that the latest commit will restart various services when their packages are updated, to help keep servo-master's running services in sync with what's on disk. If you'd prefer to manually restart any of these packages, just let me know which ones and I'll drop them back down from watch to require. (Ideally they'd all be crash/restart safe 😄)

@Manishearth
Copy link
Member

Manishearth commented Nov 5, 2015

Restarting homu/buildbot at the wrong time can break things.

Then again, we don't really update packages much (oh the horror)

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 5, 2015

OK, that's what I was thinking based on the wiki. With this PR, homu won't restart if the git checkout is updated, but it will restart automatically if either of its configuration files are updated - let me know if you want me to have it never restart automatically.

@Manishearth
Copy link
Member

Manishearth commented Nov 5, 2015

I thought that was already the case?

We only really update the conf files from salt, so homu gets restarted anyway

@aneeshusa
Copy link
Member Author

aneeshusa commented Nov 5, 2015

Hmm, looks like you're right. I rearranged the states a bit and thought I changed it.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 11, 2016

@Manishearth @aneeshusa Where are we at with this? Is it OK to leave, or are we still waiting for some changes and a rebase?

@aneeshusa
Copy link
Member Author

aneeshusa commented Feb 11, 2016

I think this was OK, but I'll give it a rebase and take a look.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 11, 2016

Thanks, no rush! I was just trying to look across our repos and see what PRs are stalled, especially if it's on the reviewer-side :-)

@aneeshusa
Copy link
Member Author

aneeshusa commented Feb 11, 2016

I actually had just sat down to put in some work for this repo, I blocked off a few hours for it today :)

@aneeshusa aneeshusa force-pushed the aneeshusa:ensure-python3-venv-for-homu branch from a844419 to b3057ca Feb 11, 2016
aneeshusa added 3 commits Nov 3, 2015
- Trusty comes with python3, pip and virtualenv by default, but write
states defensively to install these dependencies as required and require
the pip or virtualenv states as used by other states.
- Homu requires a python3 toolchain, use virtualenv-3.4 and pass python:
  python3 to get the correct setup (including pip3 inside the venv).
- Update the style guide example to use pkg.installed instead of
  pip.installed to avoid muddling it with a require: pip.
Fixes #142.
servo-master is updated in-place instead of a fresh machine being built
for every update, so this ensures services are restarted when the
underlying code is updated.
@aneeshusa aneeshusa force-pushed the aneeshusa:ensure-python3-venv-for-homu branch from b3057ca to a3baeaa Feb 11, 2016
@aneeshusa
Copy link
Member Author

aneeshusa commented Feb 11, 2016

OK, ready for review.

- name: buildbot == 0.8.12
essential-dependencies:
pkg.installed:
- name: cowsay

This comment has been minimized.

@Manishearth

Manishearth Feb 11, 2016

Member
 _____________________________________ 
< a very essential dependency, indeed >
 ------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
@Manishearth
Copy link
Member

Manishearth commented Feb 11, 2016

This looks good to me.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 11, 2016

@bors-servo r+

(lgtm, too)

@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2016

📌 Commit a3baeaa has been approved by larsbergstrom

@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2016

Testing commit a3baeaa with merge dcb4771...

bors-servo added a commit that referenced this pull request Feb 11, 2016
…rgstrom

Standardize python setup, ensure homu gets python3

- Trusty comes with python3, pip and virtualenv by default, but write
states defensively to install these dependencies as required and require
the pip or virtualenv states as used by other states.
- Homu requires a python3 toolchain, use virtualenv-3.4 and pass python:
  python3 to get the correct setup (including pip3 inside the venv).
- Update the style guide example to use pkg.installed instead of
  pip.installed to avoid muddling it with a require: pip.

Fixes #142.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/148)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2016

☀️ Test successful - travis

@bors-servo bors-servo merged commit a3baeaa into servo:master Feb 11, 2016
1 of 3 checks passed
1 of 3 checks passed
code-review/reviewable Review in progress: 2 of 9 files reviewed, 4 unresolved discussions
Details
homu Testing commit a3baeaa with merge dcb4771...
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.