Skip to main content

Awesome cli tool to try out python packages

Project description

Latest version released on PyPi Package license Package is available as wheel

try is an easy-to-use cli tool to try out python packages.

Demo

Features

  • Install specific package version from PyPI

  • Install package from GitHub

  • Install in virtualenv using specific version of python

  • Specify alternative python package import name

  • Keep try environment after interactive session

  • Launch interactive python console with already imported package

  • Launch editor instead of interpreter

  • Launch arbitrary python shell instead of default python shell

Usage

try requests
try requests --ipython
try requests --shell ptipython
try requests -p 3.5
try requests -p /usr/bin/python3.4.1
try requests==2.8.1
try kennethreitz/requests --ipython
try click-didyoumean:click_didyoumean  # if python package name is different then pip package name
try requests --editor

Usage examples

Note: most of the following cli options can also be configured in the configuration file!

Try single python package:

try requests
try flask

Try multiple python packages in one session:

try requests flask

Try specific version of a package:

try requests==2.8.1  # tries version 2.8.1 of requests instead of latest

Try package from GitHub repository:

try <user>/<repo>  # syntax example
try kennethreity/requests  # installs master branch of Kenneth's requests package from GitHub

Try package but import with different name than package name:

try <package_name>:<import_name>  # syntax example
try click-didyoumean:click_didyoumean  # install click-didyoumean but import click_didyoumean

Try package in already existing virtualenv:

try requests --virtualenv ~/.try/sandbox  # use virtualenv at ~/.try/sandbox

⇢ see virtualenv config value in env section in configuration file.

Try package with specific python version:

try requests --python 3.5  # use python3.5 in virtualenv
try requests -p 2.7  # use python2.7 in virtualenv
try requests -p ~/work/cpython/bin/python  # use python binary from specific location

⇢ see python config value in env section in configuration file.

Try package with specific shell/repl:

try requests --shell python  # use python repl (default value)
try requests --shell ipython  # use ipython
try requests --shell ptpython  # use ptpython
try requests --shell ptipython  # use ptipython
try requests --shell bpython  # use bpython
try requests --ipython  # use ipython - an alias for --shell ipython

⇢ see shell config value in env section in configuration file.

Try package writing a little script instead of opening shell:

try requests --editor  # opens $EDITOR or editor instead of shell

⇢ see always_use_editor config value in env section in configuration file.

Keep virtualenv files after try run:

try requests --keep

⇢ see keep config value in env section in configuration file.

Use a specific location for the virtualenv files:

try requests --tmpdir ~/.try

⇢ see tmpdir config value in env section in configuration file.

Configuration

try can be configured to your preferences - like always use ipython as a shell or always use python3.5. The configuration file is located in your users application configuration directory in a file called config.ini. This location is OS dependent and as specified here: http://click.pocoo.org/5/api/#click.get_app_dir

The following config.ini file shows all available configuration options:

[env]
virtualenv=~/.try/sandbox
python=3.5
shell=ipython
keep=false
always_use_editor=false
tmpdir=~/.try

Installation

Use pip to install try:

pip3 install trypackage

Help

try comes with an awesome CLI interface thanks to click.

Usage: try [OPTIONS] [PACKAGES]...

  Easily try out python packages.

Options:
  --virtualenv TEXT  Use already existing virtualenv.
  -p, --python TEXT  The python version to use.
  --ipython          Use ipython instead of python.
  --shell TEXT       Specify the python shell to use. (This will override
                     --ipython
  -k, --keep         Keep try environment files.
  --editor           Try with editor instead of interpreter.
  --tmpdir TEXT      Specify location for temporary directory.
  --version          Show the version and exit.
  --help             Show this message and exit.

try was inspired by https://github.com/VictorBjelkholm/trymodule.

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

trypackage-0.2.3.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

trypackage-0.2.3-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file trypackage-0.2.3.tar.gz.

File metadata

  • Download URL: trypackage-0.2.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for trypackage-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1b314b25948ecd430d23d952c647994d325df6f4617d21aed771e952842dc564
MD5 2210ae71bd64e577e5ccbebe823ffa02
BLAKE2b-256 8b4ef091761faccb3e595678bea474b21aa8149de5209828d854a5a6dced5a54

See more details on using hashes here.

Provenance

File details

Details for the file trypackage-0.2.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for trypackage-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 294708a224cdb812cc330e1a8088d9a909af71fa56d1ddad5e3c2075a6b9e1f9
MD5 ca06c27eeb7891090001420c5aedfbac
BLAKE2b-256 1ba605f4a40b3693cb869edc0e21f624d1b366f6a36d035225c1dbe438ac7eac

See more details on using hashes here.

Provenance

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