1<!DOCTYPE html> 2 3<html lang="en" data-content_root="./"> 4 <head> 5 <meta charset="utf-8" /> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" /> 7 8 <title>Welcome to Invoke! — Invoke documentation</title> 9 <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=6625fa76" /> 10 <link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=cb25574f" /> 11
11<script src="_static/documentation_options.js?v=5929fcd5"></script>
11 12
12<script src="_static/doctools.js?v=888ff710"></script>
12 13
13<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
13 14 <link rel="index" title="Index" href="genindex.html" /> 15 <link rel="search" title="Search" href="search.html" /> 16 <link rel="next" title="Changelog" href="changelog.html" /> 17 18 <link rel="stylesheet" href="_static/custom.css" type="text/css" /> 19 20 21 <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> 22 23
23<script async type="text/javascript" src="/_/static/javascript/readthedocs-addons.js"></script>
23<meta name="readthedocs-project-slug" content="invoke-www" /><meta name="readthedocs-version-slug" content="latest" /><meta name="readthedocs-resolver-filename" content="/" /><meta name="readthedocs-http-status" content="200" /></head><body> 24 25 26 <div class="document"> 27 <div class="documentwrapper"> 28 <div class="bodywrapper"> 29 30 31 <div class="body" role="main"> 32 33 <p><a class="reference external" href="https://pypi.org/project/invoke/"><img alt="PyPI - Package Version" src="https://img.shields.io/pypi/v/invoke" /></a> <a class="reference external" href="https://pypi.org/project/invoke/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/invoke" /></a> <a class="reference external" href="https://github.com/pyinvoke/invoke/blob/main/LICENSE"><img alt="PyPI - License" src="https://img.shields.io/pypi/l/invoke" /></a> <a class="reference external" href="https://app.circleci.com/pipelines/github/pyinvoke/invoke"><img alt="CircleCI" src="https://img.shields.io/circleci/build/github/pyinvoke/invoke/main" /></a> <a class="reference external" href="https://app.codecov.io/gh/pyinvoke/invoke"><img alt="Codecov" src="https://img.shields.io/codecov/c/gh/pyinvoke/invoke" /></a></p> 34<section id="welcome-to-invoke"> 35<h1>Welcome to Invoke!<a class="headerlink" href="#welcome-to-invoke" title="Link to this heading">¶</a></h1> 36<p>Invoke is a Python library for managing shell-oriented subprocesses and 37organizing executable Python code into CLI-invokable tasks. It draws 38inspiration from various sources (<code class="docutils literal notranslate"><span class="pre">make</span></code>/<code class="docutils literal notranslate"><span class="pre">rake</span></code>, Fabric 1.x, etc) to arrive 39at a powerful & clean feature set.</p> 40<p>To find out whatâs new in this version of Invoke, please see <a class="reference external" href="https://pyinvoke.org/changelog.html#{}">the changelog</a>.</p> 41<p>For a high level introduction, including example code, please see <a class="reference external" href="https://pyinvoke.org">our main 42project website</a>; or for detailed API docs, see <a class="reference external" href="https://docs.pyinvoke.org">the 43versioned API website</a>.</p> 44<p>The project maintainer keeps a <a class="reference external" href="https://bitprophet.org/projects#roadmap">roadmap</a> on his website.</p> 45<p>This website covers project information for Invoke such as the changelog, 46contribution guidelines, development roadmap, news/blog, and so forth. 47Detailed usage and API documentation can be found at our code documentation 48site, <a class="reference external" href="https://docs.pyinvoke.org">docs.pyinvoke.org</a>.</p> 49<p>Please see below for a high level intro, or the navigation on the left for the 50rest of the site content.</p> 51<section id="what-is-invoke"> 52<h2>What is Invoke?<a class="headerlink" href="#what-is-invoke" title="Link to this heading">¶</a></h2> 53<ul> 54<li><p>Like Rubyâs Rake tool and Invokeâs own predecessor Fabric 1.x, it provides a 55clean, high level API for running shell commands and defining/organizing 56task functions from a <code class="docutils literal notranslate"><span class="pre">tasks.py</span></code> file:</p> 57<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">invoke</span><span class="w"> </span><span class="kn">import</span> <span class="n">task</span> 58 59<span class="nd">@task</span> 60<span class="k">def</span><span class="w"> </span><span class="nf">clean</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">docs</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">bytecode</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">extra</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span> 61 <span class="n">patterns</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"build"</span><span class="p">]</span> 62 <span class="k">if</span> <span class="n">docs</span><span class="p">:</span>
63 <span class="n">patterns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"docs/_build"</span><span class="p">)</span> 64 <span class="k">if</span> <span class="n">bytecode</span><span class="p">:</span> 65 <span class="n">patterns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"**/*.pyc"</span><span class="p">)</span> 66 <span class="k">if</span> <span class="n">extra</span><span class="p">:</span> 67 <span class="n">patterns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">extra</span><span class="p">)</span> 68 <span class="k">for</span> <span class="n">pattern</span> <span class="ow">in</span> <span class="n">patterns</span><span class="p">:</span> 69 <span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="sa">f</span><span class="s2">"rm -rf </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> 70 71<span class="nd">@task</span> 72<span class="k">def</span><span class="w"> </span><span class="nf">build</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">docs</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> 73 <span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"python setup.py build"</span><span class="p">)</span> 74 <span class="k">if</span> <span class="n">docs</span><span class="p">:</span> 75 <span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"sphinx-build docs docs/_build"</span><span class="p">)</span> 76</pre></div> 77</div> 78</li> 79<li><p>From GNU Make, it inherits an emphasis on minimal boilerplate for common 80patterns and the ability to run multiple tasks in a single invocation:</p> 81<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ invoke clean build 82</pre></div> 83</div> 84</li> 85<li><p>Where Fabric 1.x considered the command-line approach the default mode of 86use, Invoke (and tools built on it) are equally at home embedded in your own 87Python code or a REPL:</p> 88<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span><span class="w"> </span><span class="nn">invoke</span><span class="w"> </span><span class="kn">import</span> <span class="n">run</span> 89<span class="gp">>>> </span><span class="n">cmd</span> <span class="o">=</span> <span class="s2">"pip install -r requirements.txt"</span> 90<span class="gp">>>> </span><span class="n">result</span> <span class="o">=</span> <span class="n">run</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">hide</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">warn</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> 91<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">ok</span><span class="p">)</span> 92<span class="go">True</span> 93<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> 94<span class="go">Successfully installed invocations-0.13.0 pep8-1.5.7 spec-1.3.1</span> 95</pre></div> 96</div> 97</li> 98<li><p>Following the lead of most Unix CLI applications, it offers a traditional 99flag-based style of command-line parsing, deriving flag names and value types 100from task signatures (optionally, of course!):</p> 101<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ invoke clean --docs --bytecode build --docs --extra='**/*.pyo' 102$ invoke clean -d -b build --docs -e '**/*.pyo' 103$ invoke clean -db build -de '**/*.pyo' 104</pre></div> 105</div> 106</li> 107<li><p>Like many of its predecessors, it offers advanced features as well â 108namespacing, task aliasing, before/after hooks, parallel execution and more.</p></li> 109</ul> 110<div class="toctree-wrapper compound"> 111</div> 112</section> 113</section> 114 115 116 </div> 117 118 </div> 119 </div> 120 <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> 121 <div class="sphinxsidebarwrapper"> 122<h1 class="logo"><a href="#">Invoke</a></h1> 123 124 125 126<p class="blurb">Pythonic task execution</p> 127 128 129 130 131<p> 132<iframe src="https://ghbtns.com/github-btn.html?user=pyinvoke&repo=invoke&type=watch&count=true&size=large&v=2" 133 allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe> 134</p> 135 136 137 138 139 140<h3>Navigation</h3> 141<ul> 142<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li> 143<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQs</a></li> 144<li class="toctree-l1"><a class="reference internal" href="installing.html">Installing</a></li> 145<li class="toctree-l1"><a class="reference internal" href="development.html">Development</a></li> 146<li class="toctree-l1"><a class="reference internal" href="prior-art.html">Prior art</a></li> 147<li class="toctree-l1"><a class="reference internal" href="contact.html">Contact</a></li> 148</ul> 149 150 151<hr /> 152<ul> 153 154 <li class="toctree-l1"><a href="https://docs.pyinvoke.org">Documentation</a></li> 155 156</ul> 157 158<div id="searchbox" style="display: none" role="search"> 159 <h3 id="searchlabel">Quick search</h3> 160 <div class="searchformwrapper"> 161 <form class="search" action="search.html" method="get"> 162 <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> 163 <input type="submit" value="Go" /> 164 </form> 165 </div> 166</div>
167<script>document.getElementById('searchbox').style.display = "block"</script>
167 168 169 170<h3 class="donation">Donate/support</h3> 171 172 173 174 175 176 177 178<p> 179Professionally-supported Invoke is available with the 180<a href="https://tidelift.com/subscription/pkg/pypi-invoke?utm_source=pypi-invoke&utm_medium=referral&utm_campaign=docs">Tidelift Subscription</a>. 181</p> 182 183 </div> 184 </div> 185 <div class="clearer"></div> 186 </div> 187 <div class="footer"> 188 ©2026 Jeff Forcier. 189 190 | 191 Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a> 192 & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> 193 194 | 195 <a href="_sources/index.rst.txt" 196 rel="nofollow">Page source</a> 197 </div> 198 199 200 201 202
202<script type="text/javascript"> 203 204 var _gaq = _gaq || []; 205 _gaq.push(['_setAccount', 'UA-18486793-3']); 206 _gaq.push(['_setDomainName', 'none']); 207 _gaq.push(['_setAllowLinker', true]); 208 _gaq.push(['_trackPageview']); 209 210 (function() { 211 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 212 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 213 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 214 })(); 215 216 </script>
216 217 218 </body> 219</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.