-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use Python 3 in example #2397
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
Use Python 3 in example #2397
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,17 @@ This example has 2 build stages: | |
Here's what the `.travis.yml` config could look like: | ||
|
||
```yaml | ||
dist: xenial | ||
|
||
env: | ||
global: | ||
# include $HOME/.local/bin for `aws` | ||
- PATH=$HOME/.local/bin:$PATH | ||
|
||
before_install: | ||
# set up awscli packages | ||
- pip install --user awscli | ||
- pyenv global 3.7.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just put at the top of the script:
Or leave out the second line to default to Python 3.6. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the example is meant to work regardless of the language setting, because people may want to use the technique on projects in various languages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Now I understand. Pyenv is superslow so what about this approach which works on Trustry, Xenial, and Bionic?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I set up a tiny test repository to experiment with what is possible on Travis. I couldn't find any way to use pip on Python 3 without either invoking pyenv or installing pip first - I assume either of those options is unwanted hassle. Feel free to play around and see if there's something I missed, though. So I think before this example can be changed, it would be necessary to change the default Travis build images, e.g. to include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, it works if you install pip first. But I'd imagine people won't especially want an extra install-the-installer step given that the example as it stands works without that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pyenv takes a minute and a half to build Python 3. I'd imagine people won't especially want an extra slow install-a-language-that-I-don't-need-and-is-already-present step... Also, pip install -U pip is effectively install-the-installer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, compared to the example as it currently is, using Python 2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a go at adding pip-on-Python 3 to the default images, but I don't really know the infrastructure, I just found a likely looking bit of code: |
||
- pip install -U pip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to more explicitly use --upgrade than -U to avoid confusion because pip also has a --user option. |
||
- pip install awscli | ||
- mkdir -p ~/$TRAVIS_BUILD_NUMBER | ||
- aws s3 sync s3://travis-build-stages-shared-storage-test/$TRAVIS_BUILD_NUMBER ~/$TRAVIS_BUILD_NUMBER | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is now optional as xenial is the default distro.