Welcome to pip-run documentation!

pip_run.run(args=None)

Main entry point for pip-run.

pip_run.commands.intercept(args)

Detect certain args and intercept them.

pip_run.commands.parse_script_args(args)

Separate the command line arguments into arguments for pip and arguments to Python.

>>> parse_script_args(['foo', '--', 'bar'])
(['foo'], ['bar'])
>>> parse_script_args(['foo', 'bar'])
(['foo', 'bar'], [])
pip_run.deps.load(*args)
pip_run.deps.pkg_installed(spec)
class pip_run.deps.suppress(*exceptions)

Bases: contextlib.suppress, contextlib.ContextDecorator

A version of contextlib.suppress with decorator support.

>>> @suppress(KeyError)
... def key_error():
...     {}['']
>>> key_error()
pip_run.deps.with_prereleases(spec)

Allow prereleases to satisfy the spec.

class pip_run.launch.PathReader

Bases: object

pip_run.launch.with_path(target, params)

Launch Python with target on the path and params

pip_run.launch.with_path_overlay(target, params)

Overlay Python with target on the path and params

class pip_run.scripts.Dependencies(iterable=(), /)

Bases: list

index_url = None
params()
class pip_run.scripts.DepsReader(script)

Bases: object

Given a Python script, read the dependencies it declares. Does not execute the script, so expects __requires__ to be assigned a static list of strings.

read()
>>> DepsReader("__requires__=['foo']").read()
['foo']
>>> DepsReader(r"__requires__='foo\nbar\n#baz'").read()
['foo', 'bar']
classmethod search(params)

Given a (possibly-empty) series of parameters to a Python interpreter, return any dependencies discovered in a script indicated in the parameters. Only honor the first file found.

classmethod try_read(script_path)
class pip_run.scripts.NotebookDepsReader(script)

Bases: pip_run.scripts.DepsReader

classmethod load(script_path)
class pip_run.scripts.SourceDepsReader(script)

Bases: pip_run.scripts.DepsReader

classmethod load(script_path)
pip_run.scripts.run(cmdline)

Execute the script as if it had been invoked naturally.

Indices and tables