Skip to main content

A simple API for pyenv

Project description

Build Status Latest Version Support MIT License

This package provides an API in the form of a wrapper around pyenv. It can be used to install, uninstall and switch Python versions.

Note: This document is based on virtualenv-api README.

Installation

The latest stable release is available on PyPi:

$ pip install pyenv-api

Please note that the distribution is named pyenv-api, yet the Python package is named pyenvapi.

Alternatively, you may fetch the latest version from git:

$ pip install git+https://github.com/ulacioh/pyenv-api.git

Usage

pyenvapi package provides a class named PyenvAPI that lets to interact, through his methods, with pyenv subcommands and options:

from pyenvapi import PyenvAPI

pyenv = PyenvAPI()

Note: if pyenv utility is not installed on your system when you will try to get a PyenvAPI instance, a NotInstalledError would be raised.

Operations

Once you have a PyenvAPI object, you can perform operations on it.

  • Get a tuple of versions installed via pyenv itself:

>>> pyenv.installed
('2.7.2', '3.7.0', '3.8.0')
  • Get, set and unset the global Python version:

>>> pyenv.global_version # Get
('system',)

>>> pyenv.global_version = ('3.8.0',) # Set

# You can also set more than one version as global
# or use a list:
>>> pyenv.global_version = ['2.7.2', '3.8.0']

>>> del pyenv.global_version # Unset
# This last example set the 'system' version as global.
  • Get a tuple of available Python versions to install:

>>> pyenv.available
('Python versions tuple, too many versions...',)
>>> ps = pyenv.install('3.6.0')
# `install` method returns a `subprocess.Popen` object

>>> type(ps)
<class 'subprocess.Popen'>
  • Uninstall a Python version:

>>> ps = pyenv.uninstall('3.6.0')
# `uninstall` method returns a tuple with
# information of the terminated child process.

>>> returncode, stdout, stderr = ps
# `returncode` - Exit status of the child process
# `stdout` - A bytes sequence of the captured stdout
# `stderr` - A bytes sequence of the captured stderr

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyenv-api-1.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pyenv_api-1.1.0-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyenv-api-1.1.0.tar.gz.

File metadata

  • Download URL: pyenv-api-1.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for pyenv-api-1.1.0.tar.gz
Algorithm Hash digest
SHA256 330420c05460432dd4b630278a3b78c3ad339ac2f062bc46a6da5eb1aa2c915d
MD5 2795c7f0b7b2c55c569f4c93f50498d9
BLAKE2b-256 ddec00f56870b94dea97fc14bfffa7e9e8ea938c3508e23a60f99fe989268f44

See more details on using hashes here.

File details

Details for the file pyenv_api-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyenv_api-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for pyenv_api-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 02e4fc399409c5e120563d58d6ef62cc9f3cb921f34532128bcd28f43dfc0bfd
MD5 fe15337e7f03dd17367eeb120e94c6be
BLAKE2b-256 e9c7bfa2a0fd838658b399e6916f784cb8a68a3e8ae6bf888a9b358cbefc0b92

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page