-
Notifications
You must be signed in to change notification settings - Fork 0
Python
Python is a programming language that lets you work more quickly and integrate your systems more effectively. It comes pre-installed in nearly every macOS and Linux installation. It is easy to learn, easy to write, and easy to maintain.
brew search python | grep "python@" | sort --version-sort
brew install python@{VERSION}
I would strongly recommend installing multiple versions of Python using Homebrew.
Other solutions (e.g., pyenv, tox
, nox
) involve compiling source code from scratch, which means working out the C libraries that need to be installed first, and how to install/configure them.
If you want to write tests using tox
/nox
which install and run multiple versions of Python, I would strongly recommend using a Docker container. The official Debian image is a good one to use.
Poetry (Recommended)
Poetry is a modern tool for installing and managing dependencies with virtual environments. It uses the modern pyproject.toml file to manage dependencies, and manages its own virtual environment.
# Add dependencies
brew install poetry
poetry init
poetry add --group=dev Sphinx
# Install dependencies
poetry install
pipenv
uses the Pipfile file to manage dependencies, and manages its own virtual environment. It's better than pip
, but not as good as Poetry.
# Add dependencies
brew install pipenv
pipenv install Sphinx
# Install dependencies
pipenv install
The old-school standard. pip
has been shipping with Python for a very long time. It uses the outdated requirements.txt file to manage dependencies. It should always be used in collaboration with venv.
# Add dependencies
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install Sphinx
python3 -m pip freeze > requirements.txt
# Install dependencies
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
PyPy is a replacement for CPython. The main reason to use it instead of CPython is speed — it runs generally faster. Our main executable comes with a Just-in-Time compiler. It is really fast in running most benchmarks—including very large and complicated Python applications, not just 10-liners.
So the case where PyPy works best is when executing long-running programs where a significant fraction of the time is spent executing Python code. This is the case covered by the majority of our benchmarks, but not all of them --- the goal of PyPy is to get speed but still support (ideally) any Python program.
brew install pypy
I would strongly recommend installing multiple versions of PyPy using Homebrew.
Other solutions (e.g., pyenv, tox
, nox
) involve compiling source code from scratch, which means working out the C libraries that need to be installed first, and how to install/configure them.
If you want to write tests using tox
/nox
which install and run multiple versions of Python, I would strongly recommend using a Docker container. The official Debian image is a good one to use.