-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Use Python 3 in example #2397
Conversation
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.
what is wrong with the current documentation? Our python builds generally use virtualenv to manage the run times, and I believe $HOME/.local/bin
is a better choice than /opt/…
.
Please read this article: https://dev.to/methane/use-pip3-to-install-awscli-44pk
Note that this is not a Python build. What is the preferred way to use Python 3 & pip on non Python builds? |
We should fix the example if it's broken, but that should be independent of the use of Python 2 or 3. |
A bit more context: projects are looking at package download statistics to evaluate when it's reasonable to drop Python 2 compatibility. But for some use cases - like Unfortunately, there doesn't seem to be any simple way to use Python 3 on a non-Python build without calling So maybe the first step is to tweak the build environments to make it easy to use |
Show available Python runtimes #1763 has been open for quite some time. @BanzaiMan Should I close this one as we have this one, too? |
I think that's a separate question - I don't follow it entirely, but it looks like it's about the list of Python versions available which can be specified in a The example in question here involves using Python in a non-Python build, i.e. where you're building software in some other language, and you need some tool which happens to be written in Python. |
@@ -11,14 +11,17 @@ This example has 2 build stages: | |||
Here's what the `.travis.yml` config could look like: | |||
|
|||
```yaml | |||
dist: xenial |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just put at the top of the script:
language: python
python: 3.7
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 comment
The 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 comment
The 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?
- python3 -m pip || wget -qO- https://bootstrap.pypa.io/get-pip.py | sudo -H python3
- python3 -m pip install --user awscli
- aws --version # aws-cli/1.16.217 Python/3.5.2 Linux/4.15.0-1028-gcp botocore/1.12.207
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.
No module named pip
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 python3-pip
package.
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.
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.
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 comment
The 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 comment
The 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 comment
The 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:
# set up awscli packages | ||
- pip install --user awscli | ||
- pyenv global 3.7.1 | ||
- pip install -U pip |
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.
It would be better to more explicitly use --upgrade than -U to avoid confusion because pip also has a --user option.
Has the new example in this PR been tested? If so, please provide a link. I also note that it should be tested under different circumstances (with respect to language, os, etc.). |
It would be nice if pyenv in Travis was upgraded to allow Python 3.8 to work in this fashion. |
.travis.yml in https://github.com/cclauss/Travis-CI-languages-by-operating-system might be a good starting point for exploration. |
* Use Python 3 in example * Update share-files-s3.md Co-authored-by: Petra <[email protected]>
Python 2 will be EOL at 2020-01-01. Please recommend people to use Python 3.