mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-02-14 17:49:53 +00:00
feat: add python installer
This commit is contained in:
109
python/README.md
Normal file
109
python/README.md
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
title: Python 3 (via pyenv)
|
||||
homepage: https://webinstall.dev/pyenv
|
||||
tagline: |
|
||||
Python is an easy-to-learn, introductory programming language.
|
||||
---
|
||||
|
||||
To update or switch versions, run `pyenv install -v 3` (or `3.10`, etc).
|
||||
|
||||
### How to Install python3 on macOS
|
||||
|
||||
Make sure that you already have Xcode tools installed:
|
||||
|
||||
```bash
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
You may also need to install Xcode proper from the App Store.
|
||||
|
||||
### How to Install python3 on Linux
|
||||
|
||||
Make sure that you already have the necessary build tools installed:
|
||||
|
||||
```bash
|
||||
# required
|
||||
sudo apt update
|
||||
sudo apt install -y build-essential zlib1g-dev libssl-dev
|
||||
|
||||
# recommended
|
||||
sudo apt install -y libreadline-dev libbz2-dev libsqlite3-dev
|
||||
```
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```txt
|
||||
~/.bashrc (or your shell's equivalent)
|
||||
~/.config/envman/PATH.env
|
||||
~/.pyenv
|
||||
```
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||

|
||||
|
||||
Python is a introductory programming language that focuses on Software
|
||||
Engineering principles - as laid out in _The Zen of Python_ (above).
|
||||
|
||||
Note: `pyenv` (used here) is the only way you should ever install Python,
|
||||
otherwise you risk messing up your system version of python, and existing python
|
||||
projects.
|
||||
|
||||
## How to reset to the system python?
|
||||
|
||||
`pyenv` installs a conflict-free version of python that will not interfere with
|
||||
system utilities (which is why we love it so much).
|
||||
|
||||
However, in the rare event that you need to switch your user profile's python
|
||||
back to the system version, you can do so:
|
||||
|
||||
```bash
|
||||
pyenv global system
|
||||
```
|
||||
|
||||
## How to use a specific version of python in a project?
|
||||
|
||||
Go into the root of your project repository and run this, for example:
|
||||
|
||||
```bash
|
||||
pyenv local -v 3.10.0
|
||||
```
|
||||
|
||||
Change 3.10.0 to the version you want for that project, of course. 😁
|
||||
|
||||
## Where to learn Python?
|
||||
|
||||
[Learn Python 3 The Hard Way](https://learnpythonthehardway.org) is probably the
|
||||
best beginner resource.
|
||||
|
||||
- [Physical Book + Video Course](https://amzn.to/3opwwxT) -
|
||||
- [eBook + Video Course](https://shop.learncodethehardway.org/access/buy/9/)
|
||||
- [Free Digital Copy](https://learnpythonthehardway.org/python3/)
|
||||
|
||||
## What to learn after Python?
|
||||
|
||||
Python's a great language for learning to program and it still has a lot of
|
||||
practical uses, but it's a product of its time and not as well-suited for modern
|
||||
web development as more modern languages that were designed to handle the types
|
||||
of problems that exist for programmers in today's world.
|
||||
|
||||
What are the best alternatives?
|
||||
|
||||
- [Go](https://webinstall.dev/golang) is a better choice for systems programming
|
||||
and web development, and "is a language you can learn in a weekend".
|
||||
- [Rust](https://webinstall.dev/rustlang) is a better choice for games and
|
||||
machine learning, but may be more difficult to master.
|
||||
- [Node](https://webinstall.dev/node) is a better choice for web programming and
|
||||
programmer tooling.
|
||||
|
||||
That all said, it's probably still worth it to learn Python first - it has much
|
||||
better learning resources than Node, and the learning resources for Go and Rust
|
||||
typically assume you've had experience with one of the languages they replace...
|
||||
such as Python.
|
||||
|
||||
Once you learn _how to program_, you can easily apply that to _any_ language.
|
||||
|
||||
90%+ of programming is _programming_. Maybe 10% is the language you choose.
|
||||
38
python/install.sh
Normal file
38
python/install.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
function __init_python() {
|
||||
if [[ ! -x "${HOME}/.pyenv/bin/pyenv" ]]; then
|
||||
"${HOME}/.local/bin/webi" "pyenv"
|
||||
fi
|
||||
export PATH="${HOME}/.pyenv/bin:${PATH}"
|
||||
export PATH="${HOME}/.pyenv/shims:${PATH}"
|
||||
|
||||
#eval "$(pyenv init -)"
|
||||
#eval "$(pyenv virtualenv-init -)"
|
||||
|
||||
pyenv update
|
||||
|
||||
my_latest_python3="$(
|
||||
pyenv install --list |
|
||||
grep -v -- - |
|
||||
grep '3\.[0-9]\+\.[0-9]\+$' |
|
||||
tail -n 1 |
|
||||
cut -d' ' -f3
|
||||
)"
|
||||
|
||||
#my_python="${WEBI_VERSION:-${my_latest_python3}}"
|
||||
my_python="${my_latest_python3}"
|
||||
echo "Installing ${my_python}"
|
||||
pyenv install -v "${my_python}"
|
||||
pyenv global "${my_python}"
|
||||
|
||||
echo ''
|
||||
echo 'NOTE: You may also need to CLOSE and RE-OPEN your terminal for pyenv to take effect.'
|
||||
echo '(to switch versions of python, see https://webinstall.dev/pyenv)'
|
||||
echo ''
|
||||
}
|
||||
|
||||
__init_python
|
||||
54
python2/README.md
Normal file
54
python2/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: Python 2 (via pyenv)
|
||||
homepage: https://webinstall.dev/pyenv
|
||||
tagline: |
|
||||
Python 2 is the legacy version of Python.
|
||||
---
|
||||
|
||||
To update or switch versions, run `pyenv install -v 2` (or `2.6`, etc).
|
||||
|
||||
### How to Install python2 on macOS
|
||||
|
||||
Make sure that you already have Xcode tools installed:
|
||||
|
||||
```bash
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
You may also need to install Xcode proper from the App Store.
|
||||
|
||||
### How to Install python2 on Linux
|
||||
|
||||
Make sure that you already have the necessary build tools installed:
|
||||
|
||||
```bash
|
||||
# required
|
||||
sudo apt update
|
||||
sudo apt install -y build-essential zlib1g-dev libssl-dev
|
||||
|
||||
# recommended
|
||||
sudo apt install -y libreadline-dev libbz2-dev libsqlite3-dev
|
||||
```
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```txt
|
||||
~/.bashrc (or your shell's equivalent)
|
||||
~/.config/envman/PATH.env
|
||||
~/.pyenv
|
||||
```
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||

|
||||
|
||||
Unless you know you need Python 2 for a specific purpose, you should probably
|
||||
use [Python 3](/python) instead.
|
||||
|
||||
For more info see these cheat sheets:
|
||||
|
||||
- [Python 3](/python)
|
||||
- [pyenv](/pyenv)
|
||||
38
python2/install.sh
Normal file
38
python2/install.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
function __init_python2() {
|
||||
if [[ ! -x "${HOME}/.pyenv/bin/pyenv" ]]; then
|
||||
"${HOME}/.local/bin/webi" "pyenv"
|
||||
fi
|
||||
export PATH="${HOME}/.pyenv/bin:${PATH}"
|
||||
export PATH="${HOME}/.pyenv/shims:${PATH}"
|
||||
|
||||
#eval "$(pyenv init -)"
|
||||
#eval "$(pyenv virtualenv-init -)"
|
||||
|
||||
pyenv update
|
||||
|
||||
my_latest_python2="$(
|
||||
pyenv install --list |
|
||||
grep -v -- - |
|
||||
grep '2\.[0-9]\+\.[0-9]\+$' |
|
||||
tail -n 1 |
|
||||
cut -d' ' -f3
|
||||
)"
|
||||
|
||||
#my_python="${WEBI_VERSION:-${my_latest_python2}}"
|
||||
my_python="${my_latest_python2}"
|
||||
echo "Installing ${my_python}"
|
||||
pyenv install -v "${my_python}"
|
||||
pyenv global "${my_python}"
|
||||
|
||||
echo ''
|
||||
echo 'NOTE: You may also need to CLOSE and RE-OPEN your terminal for pyenv to take effect.'
|
||||
echo '(to switch versions of python, see https://webinstall.dev/pyenv)'
|
||||
echo ''
|
||||
}
|
||||
|
||||
__init_python2
|
||||
18
python3/install.sh
Normal file
18
python3/install.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
# title: Python 3 (alias for python)
|
||||
# homepage: https://webinstall.dev/python
|
||||
# tagline: Alias for https://webinstall.dev/python
|
||||
# alias: python
|
||||
# description: |
|
||||
# See https://webinstall.dev/python
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
function __redirect_alias_python() {
|
||||
echo "'python@${WEBI_TAG:-stable}' is an alias for 'python@${WEBI_VERSION:-}'"
|
||||
WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
|
||||
curl -fsSL "$WEBI_HOST/python@${WEBI_VERSION:-}" | bash
|
||||
}
|
||||
|
||||
__redirect_alias_python
|
||||
Reference in New Issue
Block a user