Skip to main content

Command line utility to run a command, installing needed python packages if it is not installed

Project description

pypirun

Build Status Codestyle Code Coverage Wheel Version Downloads License

The pypirun command is a utility that allows running a python command line script from a python package, even if it is not installed.

Table of contents

Background

This utility was written to allow CI/CD Pipeline templates to be able to function properly when run in docker containers that did not have the python utility needed already installed.

This allows the templates to continue to work in different docker containers without requiring redundant steps to install the needed python packages.

Install

This package can be installed using the Python pip package manager.

In order to install this package the python environment must have:

  • Python 3.6 or newer
  • pip version 8.1.1 or higher
  • setuptools 40.0.0 or higher
$ pip install pypirun

Usage

usage: pypirun [-h] [--interpreter INTERPRETER] [--debug] [--always_install] package command ...

positional arguments:
  package                    Comma seperated list of packages to install, this list cannot contain spaces
  command                    Command to run

optional arguments:
  -h, --help                 show this help message and exit
  --interpreter INTERPRETER  Python interpreter to use
  --debug                    Enable debug output
  --always_install           Install the command even if it exists in the path
  --upgrade_pip              Upgrade the pip before installing packages
  --upgrade_setuptools       Upgrade setuptools before installing packages

Everything on the command line after the package name is executed in an environment with the package installed and on 
the PATH.  As a result, the package and command must come after the optional arguments.

By default pypirun will run the already installed command from the $PATH in the environment if it is found.  The
--always_install flag will force it to install and run the command.

Examples

Run the serviceping utility from the python serviceping package

The following will run the command serviceping -c 1 yahoo.com from the serviceping package:

$ pypirun serviceping serviceping -c 1 yahoo.com
SERVICEPING yahoo.com:80 (72.30.35.10:80).
from yahoo.com:80 (72.30.35.10:80): time=65.50 ms                                                                                                                                                                                                                 --- yahoo.com ping statistics ---
1 packages transmitted, 1 received, 0.0% package loss, time 73.038ms
rtt min/avg/max/dev = 65.50/65.50/65.50/0.00 ms

Run the screwdrivercd.installdeps module from the screwdrivercd package as a script

$ pypirun -m screwdrivercd screwdrivercd.installdeps
$

Screwdriver V4 pypirun command

The pypirun package publishes a screwdriver v4 shared command called python/pypirun.

This command will set up python if it is not installed and install and run a the pypirun command line utility.

The following will run the command serviceping -c 1 yahoo.com from the serviceping package using the screwdriver sd-cmd:

sd-cmd python/pypirun@latest serviceping serviceping -c 1 yahoo.com

Contribute

Please refer to the contributing.md file for information about how to get involved. We welcome issues, questions, and pull requests. Pull Requests are welcome.

Maintainers

Dwight Hubbard: dhubbard@verizonmedia.com

License

This project is licensed under the terms of the BSD open source license. Please refer to LICENSE for the full terms.

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

pypirun-3.0.966010.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

pypirun-3.0.966010-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pypirun-3.0.966010.tar.gz.

File metadata

  • Download URL: pypirun-3.0.966010.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for pypirun-3.0.966010.tar.gz
Algorithm Hash digest
SHA256 14e2ddbbe4f3f4099fc868ae6e28d5fdc9124310c7278b895d2da8a0678d4fe2
MD5 f43cfbe652c191cf4120767da355f30c
BLAKE2b-256 8e28fc5c4aa7347ed158b3dc2bbfa7152ed7f8bb191659b79c6e7d31d1d0b853

See more details on using hashes here.

File details

Details for the file pypirun-3.0.966010-py3-none-any.whl.

File metadata

File hashes

Hashes for pypirun-3.0.966010-py3-none-any.whl
Algorithm Hash digest
SHA256 124e838bf3d9e90d90b125fb6bf37a3d0ad920a5b14e2c956561e37dd51188b7
MD5 4f0d7502b9a637f86564cb4e8130b895
BLAKE2b-256 d97a89f12cfdee50aa7a79ac91a2bcfe524966fca08aaab22ba0c083f981ec13

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