Skip to main content

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

Metadata

Release files for pyenv-api 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyenv-api 1.1.0
File Size Uploaded
pyenv-api-1.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyenv-api 1.1.0
File Interpreter ABI Platform
pyenv_api-1.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.2 kB

Release files / pyenv-api-1.1.0.tar.gz

Download URL pyenv-api-1.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
330420c05460432dd4b630278a3b78c3ad339ac2f062bc46a6da5eb1aa2c915d
BLAKE2b-256 checksum
How to use checksums
ddec00f56870b94dea97fc14bfffa7e9e8ea938c3508e23a60f99fe989268f44
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pyenv_api-1.1.0-py2.py3-none-any.whl

Download URL pyenv_api-1.1.0-py2.py3-none-any.whl
Size 6.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
02e4fc399409c5e120563d58d6ef62cc9f3cb921f34532128bcd28f43dfc0bfd
BLAKE2b-256 checksum
How to use checksums
e9c7bfa2a0fd838658b399e6916f784cb8a68a3e8ae6bf888a9b358cbefc0b92
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page