gop
is simple to setup, simple to use, and powerful to boot.
There are no tricky settings, options, or crazy dependencies. gop
is just a helpful tool that gets the job done, and is the Golang cousin of p
, a bash script for managing Python versions.
gop
is also great for getting started using Python development versions. Use gop latest
to get up and running with the latest development version of Python!
To build from source, install Go and then run
go get -u github.com/andrewmfiorillo/gop/cmd/gop
The two settings you may want to change are P_PREFIX
(where are installed versions are kept) and your PATH
(which makes them easily accessible)
In Linux or OSX, this would look like
# In ~/.bash_profile, or the equivalent
export P_PREFIX=$HOME
export PATH="$P_PREFIX/p/versions/bin:$PATH"
Or in Windows, you set the environment variables with Rapid Environment Editor or your favorite tool
set P_PREFIX=%USERPROFILE%
set PATH=%P_PREFIX%;%PATH%
Commands:
gop <version> Activate to Python <version>
gop ls, list Output the versions of Python available
gop ls installed Output the installed versions of Python
gop ls latest Output the latest Python version available
gop ls stable Output the latest stable Python version available
gop latest Activate to the latest Python release
gop stable Activate to the latest stable Python release
gop status Output current status
gop install <version> --force Install Python <version> but do NOT activate
gop use <version> [args ...] Execute Python <version> with [args ...]
gop bin <version> Output bin path for <version>
gop rm <version ...> Remove the given version(s)
gop default, disable Use default (system) Python installation
gop help, h [command] Shows a list of commands or help for one command
Options:
--verbose
--help, -h show help
--version, -v print the version
gop
stores each Python version installed under the directory $P_PREFIX/p/versions/python
. When a Python version is activated, p
creates symbolic links in $P_PREFIX/p/versions
, pointing to the:
bin
include
lib
share
directories of the activated Python version.
For example, Python version 3.6.5 is installed, and it will be placed under the directory:
$P_PREFIX/p/versions/python/3.6.5
Activating version 3.6.5 will create symlinks that points to directories under the activated Python installation:
$P_PREFIX/p/versions/bin -> $P_PREFIX/p/versions/python/3.6.5/bin
$P_PREFIX/p/versions/include -> $P_PREFIX/p/versions/python/3.6.5/include
$P_PREFIX/p/versions/lib -> $P_PREFIX/p/versions/python/3.6.5/lib
$P_PREFIX/p/versions/share -> $P_PREFIX/p/versions/python/3.6.5/share
$P_PREFIX
allows you to customize where python versions are installed, and defaults to $HOME
(%USERPROFILE%
on Windows) if unspecified. To use the Python that gop
installs, you must either call its full path (given with gop bin
) or add $P_PREFIX/p/versions/bin
to your $PATH
.
When installing Python 3, the symlink python
and pip
are also created for python3
and pip3
executables respectively, for the sake of convenience.
What about pip
?
pip
is installed by default for Python 3. For Python 2.7.9 or above, you can run the following command to install pip
:
python -m ensurepip
For Python version less than 2.7.9, you will have to install pip
manually.
Can I use gop
to manage Python project dependencies?
You could, though it is recommended to use pipenv
to do so. gop
can be used to install the Python version for your project, and pipenv
can later be used to setup the project virtual environment using the Python version installed.