| Server IP : 50.21.180.56 / Your IP : 216.73.216.208 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : ws67922704 ( 67922704) PHP Version : 8.5.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /kunden/usr/share/doc/python3-pip/html/development/architecture/ |
Upload File : |
<!doctype html>
<html class="no-js" lang="en" data-content_root="../../">
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="search" title="Search" href="../../search.html" /><link rel="copyright" title="Copyright" href="../../copyright.html" /><link rel="next" title="Options that control the installation process" href="upgrade-options.html" /><link rel="prev" title="Finding and choosing files (index and PackageFinder)" href="package-finding.html" />
<!-- Generated with Sphinx 8.1.3 and Furo 2024.08.06 -->
<title>Command Line Interface - pip documentation v25.1.1</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=a746c00c" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?v=ad9e2e31" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/tabs.css?v=4c969af8" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo-extensions.css?v=4aa03575" />
<style>
body {
--color-code-background: #f8f8f8;
--color-code-foreground: black;
}
@media not print {
body[data-theme="dark"] {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
}
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
}
}
}
</style></head>
<body>
<script>
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
</script>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="svg-toc" viewBox="0 0 24 24">
<title>Contents</title>
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
</svg>
</symbol>
<symbol id="svg-menu" viewBox="0 0 24 24">
<title>Menu</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</symbol>
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
<title>Expand</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</symbol>
<symbol id="svg-sun" viewBox="0 0 24 24">
<title>Light mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</symbol>
<symbol id="svg-moon" viewBox="0 0 24 24">
<title>Dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
</svg>
</symbol>
<symbol id="svg-sun-with-moon" viewBox="0 0 24 24">
<title>Auto light/dark, in light mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
<path style="opacity: 50%" d="M 5.411 14.504 C 5.471 14.504 5.532 14.504 5.591 14.504 C 3.639 16.319 4.383 19.569 6.931 20.352 C 7.693 20.586 8.512 20.551 9.25 20.252 C 8.023 23.207 4.056 23.725 2.11 21.184 C 0.166 18.642 1.702 14.949 4.874 14.536 C 5.051 14.512 5.231 14.5 5.411 14.5 L 5.411 14.504 Z"/>
<line x1="14.5" y1="3.25" x2="14.5" y2="1.25"/>
<line x1="14.5" y1="15.85" x2="14.5" y2="17.85"/>
<line x1="10.044" y1="5.094" x2="8.63" y2="3.68"/>
<line x1="19" y1="14.05" x2="20.414" y2="15.464"/>
<line x1="8.2" y1="9.55" x2="6.2" y2="9.55"/>
<line x1="20.8" y1="9.55" x2="22.8" y2="9.55"/>
<line x1="10.044" y1="14.006" x2="8.63" y2="15.42"/>
<line x1="19" y1="5.05" x2="20.414" y2="3.636"/>
<circle cx="14.5" cy="9.55" r="3.6"/>
</svg>
</symbol>
<symbol id="svg-moon-with-sun" viewBox="0 0 24 24">
<title>Auto light/dark, in dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
<path d="M 8.282 7.007 C 8.385 7.007 8.494 7.007 8.595 7.007 C 5.18 10.184 6.481 15.869 10.942 17.24 C 12.275 17.648 13.706 17.589 15 17.066 C 12.851 22.236 5.91 23.143 2.505 18.696 C -0.897 14.249 1.791 7.786 7.342 7.063 C 7.652 7.021 7.965 7 8.282 7 L 8.282 7.007 Z"/>
<line style="opacity: 50%" x1="18" y1="3.705" x2="18" y2="2.5"/>
<line style="opacity: 50%" x1="18" y1="11.295" x2="18" y2="12.5"/>
<line style="opacity: 50%" x1="15.316" y1="4.816" x2="14.464" y2="3.964"/>
<line style="opacity: 50%" x1="20.711" y1="10.212" x2="21.563" y2="11.063"/>
<line style="opacity: 50%" x1="14.205" y1="7.5" x2="13.001" y2="7.5"/>
<line style="opacity: 50%" x1="21.795" y1="7.5" x2="23" y2="7.5"/>
<line style="opacity: 50%" x1="15.316" y1="10.184" x2="14.464" y2="11.036"/>
<line style="opacity: 50%" x1="20.711" y1="4.789" x2="21.563" y2="3.937"/>
<circle style="opacity: 50%" cx="18" cy="7.5" r="2.169"/>
</svg>
</symbol>
<symbol id="svg-pencil" viewBox="0 0 24 24">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-pencil-code">
<path d="M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" />
<path d="M13.5 6.5l4 4" />
<path d="M20 21l2 -2l-2 -2" />
<path d="M17 17l-2 2l2 2" />
</svg>
</symbol>
<symbol id="svg-eye" viewBox="0 0 24 24">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-eye-code">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
<path
d="M11.11 17.958c-3.209 -.307 -5.91 -2.293 -8.11 -5.958c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6c-.21 .352 -.427 .688 -.647 1.008" />
<path d="M20 21l2 -2l-2 -2" />
<path d="M17 17l-2 2l2 2" />
</svg>
</symbol>
</svg>
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
<label class="overlay sidebar-overlay" for="__navigation">
<div class="visually-hidden">Hide navigation sidebar</div>
</label>
<label class="overlay toc-overlay" for="__toc">
<div class="visually-hidden">Hide table of contents sidebar</div>
</label>
<a class="skip-to-content muted-link" href="#furo-main-content">Skip to content</a>
<div class="page">
<header class="mobile-header">
<div class="header-left">
<label class="nav-overlay-icon" for="__navigation">
<div class="visually-hidden">Toggle site navigation sidebar</div>
<i class="icon"><svg><use href="#svg-menu"></use></svg></i>
</label>
</div>
<div class="header-center">
<a href="../../index.html"><div class="brand">pip documentation v25.1.1</div></a>
</div>
<div class="header-right">
<div class="theme-toggle-container theme-toggle-header">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-header-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
</header>
<aside class="sidebar-drawer">
<div class="sidebar-container">
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
<span class="sidebar-brand-text">pip documentation v25.1.1</span>
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getting-started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../user_guide.html">User Guide</a></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../topics/index.html">Topic Guides</a><input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" role="switch" type="checkbox"/><label for="toctree-checkbox-1"><div class="visually-hidden">Toggle navigation of Topic Guides</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../topics/authentication.html">Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/caching.html">Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/configuration.html">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/dependency-resolution.html">Dependency Resolution</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/more-dependency-resolution.html">More on Dependency Resolution</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/https-certificates.html">HTTPS Certificates</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/local-project-installs.html">Local project installs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/repeatable-installs.html">Repeatable Installs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/secure-installs.html">Secure installs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/vcs-support.html">VCS Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/python-option.html">Managing a different Python interpreter</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../topics/workflow.html">Pip is not a workflow management tool</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../reference/index.html">Reference</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" role="switch" type="checkbox"/><label for="toctree-checkbox-2"><div class="visually-hidden">Toggle navigation of Reference</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../reference/build-system/index.html">Build System Interface</a><input class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" role="switch" type="checkbox"/><label for="toctree-checkbox-3"><div class="visually-hidden">Toggle navigation of Build System Interface</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/build-system/pyproject-toml.html"><code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/build-system/setup-py.html"><code class="docutils literal notranslate"><span class="pre">setup.py</span></code> (legacy)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/requirement-specifiers.html">Requirement Specifiers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/requirements-file-format.html">Requirements File Format</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/installation-report.html">Installation Report</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/inspect-report.html"><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">inspect</span></code> JSON output specification</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../cli/index.html">Commands</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" role="switch" type="checkbox"/><label for="toctree-checkbox-4"><div class="visually-hidden">Toggle navigation of Commands</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip.html">pip</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_install.html">pip install</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_uninstall.html">pip uninstall</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_inspect.html">pip inspect</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_list.html">pip list</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_show.html">pip show</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_freeze.html">pip freeze</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_check.html">pip check</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_lock.html">pip lock</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_download.html">pip download</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_wheel.html">pip wheel</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_hash.html">pip hash</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_search.html">pip search</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_index.html">pip index</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_cache.html">pip cache</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_config.html">pip config</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cli/pip_debug.html">pip debug</a></li>
</ul>
</li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Project</span></p>
<ul class="current">
<li class="toctree-l1 current has-children"><a class="reference internal" href="../index.html">Development</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" role="switch" type="checkbox"/><label for="toctree-checkbox-5"><div class="visually-hidden">Toggle navigation of Development</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../getting-started.html">Getting Started</a></li>
<li class="toctree-l2"><a class="reference internal" href="../contributing.html">Contributing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ci.html">Continuous Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../issue-triage.html">Issue Triage</a></li>
<li class="toctree-l2 current has-children"><a class="reference internal" href="index.html">Architecture of pip’s internals</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" role="switch" type="checkbox"/><label for="toctree-checkbox-6"><div class="visually-hidden">Toggle navigation of Architecture of pip’s internals</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="overview.html">Broad functionality overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="anatomy.html">Repository anatomy & directory structure</a></li>
<li class="toctree-l3"><a class="reference internal" href="configuration-files.html">Configuration File Handling</a></li>
<li class="toctree-l3"><a class="reference internal" href="package-finding.html">Finding and choosing files (<code class="docutils literal notranslate"><span class="pre">index</span></code> and <code class="docutils literal notranslate"><span class="pre">PackageFinder</span></code>)</a></li>
<li class="toctree-l3 current current-page"><a class="current reference internal" href="#">Command Line Interface</a></li>
<li class="toctree-l3"><a class="reference internal" href="upgrade-options.html">Options that control the installation process</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../release-process.html">Release process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vendoring-policy.html">Vendoring Policy</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../ux-research-design/index.html">UX Research & Design</a><input class="toctree-checkbox" id="toctree-checkbox-7" name="toctree-checkbox-7" role="switch" type="checkbox"/><label for="toctree-checkbox-7"><div class="visually-hidden">Toggle navigation of UX Research & Design</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../ux-research-design/contribute.html">How to Contribute</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../ux-research-design/guidance.html">UX Guidance</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../ux-research-design/research-results/index.html">UX Research Results</a><input class="toctree-checkbox" id="toctree-checkbox-8" name="toctree-checkbox-8" role="switch" type="checkbox"/><label for="toctree-checkbox-8"><div class="visually-hidden">Toggle navigation of UX Research Results</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/about-our-users.html">About pip’s Users</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/mental-models.html">How Users Understand pip</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/users-and-security.html">How pip users think about security</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/ci-cd.html">How pip is used in interactive environments (i.e. CI, CD)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/personas.html">pip Personas</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/prioritizing-features.html">Prioritizing pip Features</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/override-conflicting-dependencies.html">Providing an override to install packages with conflicting dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/pip-force-reinstall.html">pip --force-reinstall</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/pip-search.html">pip search</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/pip-upgrade-conflict.html">pip Upgrade Conflict</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../ux-research-design/research-results/improving-pips-documentation.html">Improving pip’s Documentation</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../news.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/pypa/pip">GitHub</a></li>
</ul>
</div>
</div>
</div>
</div>
</aside>
<div class="main">
<div class="content">
<div class="article-container">
<a href="#" class="back-to-top muted-link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
</svg>
<span>Back to top</span>
</a>
<div class="content-icon-container">
<div class="view-this-page">
<a class="muted-link" href="../../_sources/development/architecture/command-line-interface.rst.txt" title="View this page">
<svg><use href="#svg-eye"></use></svg>
<span class="visually-hidden">View this page</span>
</a>
</div>
<div class="theme-toggle-container theme-toggle-content">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-content-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
<article role="main" id="furo-main-content">
<section id="command-line-interface">
<h1>Command Line Interface<a class="headerlink" href="#command-line-interface" title="Link to this heading">¶</a></h1>
<p>The <code class="docutils literal notranslate"><span class="pre">pip._internal.cli</span></code> package is responsible for processing and providing
pip’s command line interface. This package handles:</p>
<ul class="simple">
<li><p>CLI option definition and parsing</p></li>
<li><p>autocompletion</p></li>
<li><p>dispatching to the various commands</p></li>
<li><p>utilities like progress bars and spinners</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This section of the documentation is currently being written. pip
developers welcome your help to complete this documentation. If you’re
interested in helping out, please let us know in the
<a class="reference external" href="https://github.com/pypa/pip/issues/6831">tracking issue</a>.</p>
</div>
<section id="overview">
<span id="cli-overview"></span><h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">¶</a></h2>
<p>A <code class="docutils literal notranslate"><span class="pre">ConfigOptionParser</span></code> instance is used as the “main parser”,
for parsing top level args.</p>
<p><code class="docutils literal notranslate"><span class="pre">Command</span></code> then uses another <code class="docutils literal notranslate"><span class="pre">ConfigOptionParser</span></code> instance, to parse command-specific args.</p>
<section id="command-structure">
<h3>Command structure<a class="headerlink" href="#command-structure" title="Link to this heading">¶</a></h3>
<p>This section shows the class hierarchy from which every command’s class will inherit
from.</p>
<p><a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/base_command.py">base_command.py</a>
defines the base <code class="docutils literal notranslate"><span class="pre">Command</span></code> class, from which every other command will inherit directly or
indirectly (see the <em>command tree</em> at the end of this section).</p>
<p>Using the <code class="docutils literal notranslate"><span class="pre">ConfigOptionParser</span></code> (see <a class="reference internal" href="#configuration-and-cli-blend">Configuration and CLI “blend”</a>),
this class adds the general options and instantiates the <em>cmd_opts</em> group, where every other specific
option will be added if needed on each command’s class. For those commands that define specific
options, like <code class="docutils literal notranslate"><span class="pre">--dry-run</span></code> on <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> command, the options must be added to <em>cmd_opts</em>
this is the job of <em>add_options</em> method), which will be automatically called on <code class="docutils literal notranslate"><span class="pre">Command</span></code>’s initialization.</p>
<p>The base <code class="docutils literal notranslate"><span class="pre">Command</span></code> has the following methods:</p>
<dl class="py class">
<dt class="sig sig-object py" id="Command">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Command</span></span><a class="headerlink" href="#Command" title="Link to this definition">¶</a></dt>
<dd><dl class="py method">
<dt class="sig sig-object py" id="Command.main">
<span class="sig-name descname"><span class="pre">main</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Command.main" title="Link to this definition">¶</a></dt>
<dd><p>Main method of the class, it’s always called (as can be seen in main.py’s
<a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/main.py#L46">main</a>).
It’s in charge of calling the specific <code class="docutils literal notranslate"><span class="pre">run</span></code> method of the class and handling the possible errors.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Command.run">
<span class="sig-name descname"><span class="pre">run</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Command.run" title="Link to this definition">¶</a></dt>
<dd><p>Abstract method where the actual action of a command is defined.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Command.add_options">
<span class="sig-name descname"><span class="pre">add_options</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Command.add_options" title="Link to this definition">¶</a></dt>
<dd><p>Optional method to insert additional options on a class, called on <code class="docutils literal notranslate"><span class="pre">Command</span></code> initialization.</p>
</dd></dl>
</dd></dl>
<p>Some commands have more specialized behavior, (see for example <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">index</span></code>).
These commands instead will inherit from <code class="docutils literal notranslate"><span class="pre">IndexGroupCommand</span></code>, which inherits from <code class="docutils literal notranslate"><span class="pre">Command</span></code>
and <code class="docutils literal notranslate"><span class="pre">SessionCommandMixin</span></code> to build build the pip session for the corresponding requests.</p>
<p>Lastly, <code class="docutils literal notranslate"><span class="pre">RequirementCommand</span></code>, which inherits from <code class="docutils literal notranslate"><span class="pre">IndexGroupCommand</span></code> is the base class
for those commands which make use of requirements in any form, like <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code>.</p>
<p>In addition to the previous classes, a last mixin class must be mentioned, from which
<code class="docutils literal notranslate"><span class="pre">Command</span></code> as well as <code class="docutils literal notranslate"><span class="pre">SessionCommandMixin</span></code> inherit: <code class="docutils literal notranslate"><span class="pre">CommandContextMixIn</span></code>, in
charge of the command’s context.</p>
<p>In the following command tree we can see the hierarchy defined for the different pip
commands, where each command is defined under the base class it inherits from:</p>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Command</span></code></div>
<div class="line-block">
<div class="line">├─ <code class="docutils literal notranslate"><span class="pre">cache</span></code>, <code class="docutils literal notranslate"><span class="pre">check</span></code>, <code class="docutils literal notranslate"><span class="pre">completion</span></code>, <code class="docutils literal notranslate"><span class="pre">configuration</span></code>, <code class="docutils literal notranslate"><span class="pre">debug</span></code>, <code class="docutils literal notranslate"><span class="pre">freeze</span></code>, <code class="docutils literal notranslate"><span class="pre">hash</span></code>, <code class="docutils literal notranslate"><span class="pre">help</span></code>, <code class="docutils literal notranslate"><span class="pre">inspect</span></code>, <code class="docutils literal notranslate"><span class="pre">show</span></code>, <code class="docutils literal notranslate"><span class="pre">search</span></code>, <code class="docutils literal notranslate"><span class="pre">uninstall</span></code></div>
<div class="line">└─ <code class="docutils literal notranslate"><span class="pre">IndexGroupCommand</span></code></div>
<div class="line-block">
<div class="line">├─ <code class="docutils literal notranslate"><span class="pre">index</span></code>, <code class="docutils literal notranslate"><span class="pre">list</span></code></div>
<div class="line">└─ <code class="docutils literal notranslate"><span class="pre">RequirementCommand</span></code></div>
<div class="line-block">
<div class="line">└─ <code class="docutils literal notranslate"><span class="pre">wheel</span></code>, <code class="docutils literal notranslate"><span class="pre">download</span></code>, <code class="docutils literal notranslate"><span class="pre">install</span></code></div>
</div>
</div>
</div>
</div>
</section>
<section id="option-definition">
<h3>Option definition<a class="headerlink" href="#option-definition" title="Link to this heading">¶</a></h3>
<p>The set of shared options are defined in <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/cmdoptions.py">cmdoptions.py</a>
module, as well as the <em>general options</em> and <em>package index options</em> groups of options
we see when we call a command’s help, or the <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">index</span></code>’s help message respectively.
All options are defined in terms of functions that return <a class="reference external" href="https://docs.python.org/3/library/optparse.html#optparse.Option">optparse.Option</a>
instances once called, while specific groups of options, like <em>Config Options</em> for
<code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">config</span></code> are defined in each specific command file (see for example the
<a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/commands/configuration.py">configuration.py</a>).</p>
</section>
<section id="argument-parsing">
<h3>Argument parsing<a class="headerlink" href="#argument-parsing" title="Link to this heading">¶</a></h3>
<p>The main entrypoint for the application is defined in the <code class="docutils literal notranslate"><span class="pre">main</span></code> function in the
<a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/main.py">main.py</a> module.
This function is in charge of the <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/autocompletion.py">autocompletion</a>,
calling the <code class="docutils literal notranslate"><span class="pre">parse_command</span></code> function and creating and running the subprograms
via <code class="docutils literal notranslate"><span class="pre">create_command</span></code>, on which the <code class="docutils literal notranslate"><span class="pre">main</span></code> method is called.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">parse_command</span></code> is defined in the <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/main_parser.py">main_parser.py</a>
module, which defines the following two functions:</p>
<dl class="py function">
<dt class="sig sig-object py" id="parse_command">
<span class="sig-name descname"><span class="pre">parse_command</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#parse_command" title="Link to this definition">¶</a></dt>
<dd><p>Function in charge of the initial parse of <code class="docutils literal notranslate"><span class="pre">pip</span></code>’s program. Creates the main parser (see
the next function <code class="docutils literal notranslate"><span class="pre">create_main_parser</span></code>) to extract the general options
and the remaining arguments. For example, running <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">--timeout=5</span> <span class="pre">install</span> <span class="pre">--user</span> <span class="pre">INITools</span></code>
will split <code class="docutils literal notranslate"><span class="pre">['--timeout=5']</span></code> as general option and <code class="docutils literal notranslate"><span class="pre">['install',</span> <span class="pre">'--user',</span> <span class="pre">'INITools']</span></code>
as the remainder.</p>
<p>At this step the program deals with the options <code class="docutils literal notranslate"><span class="pre">--python</span></code>, <code class="docutils literal notranslate"><span class="pre">--version</span></code>, <code class="docutils literal notranslate"><span class="pre">pip</span></code>
or <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">help</span></code>. If neither of the previous options is found, it tries to extract the command
name and arguments.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="create_main_parser">
<span class="sig-name descname"><span class="pre">create_main_parser</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#create_main_parser" title="Link to this definition">¶</a></dt>
<dd><p>Creates the main parser (type <code class="docutils literal notranslate"><span class="pre">pip</span></code> in the console to see the description of the
program). The internal parser (<a class="reference internal" href="#configuration-and-cli-blend">ConfigOptionParser</a>),
adds the general option group and the list of commands coming from <code class="docutils literal notranslate"><span class="pre">cmdoptions.py</span></code>
at this point.</p>
</dd></dl>
<p>After the initial parsing is done, <code class="docutils literal notranslate"><span class="pre">create_command</span></code> is in charge of creating the appropriate
command using the information stored in <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/commands/__init__.py">commands_dict</a>
variable, and calling its <code class="docutils literal notranslate"><span class="pre">main</span></code> method (see <a class="reference external" href="Commandstructure">Command structure</a>).</p>
<p>A second argument parsing is done at each specific command (defined in the base <code class="docutils literal notranslate"><span class="pre">Command</span></code> class),
again using the <code class="docutils literal notranslate"><span class="pre">ConfigOptionParser</span></code>.</p>
</section>
<section id="argument-access">
<h3>Argument access<a class="headerlink" href="#argument-access" title="Link to this heading">¶</a></h3>
<p>To access all the options and arguments, <code class="docutils literal notranslate"><span class="pre">Command.run()</span></code> takes
the options as <a class="reference external" href="https://docs.python.org/3/library/optparse.html#optparse.Values">optparse.Values</a>
and a list of strings for the arguments (parsed in <code class="docutils literal notranslate"><span class="pre">Command.main()</span></code>). The internal methods of
the base <code class="docutils literal notranslate"><span class="pre">Command</span></code> class are in charge of passing these variables after <code class="docutils literal notranslate"><span class="pre">parse_args</span></code> is
called for a specific command.</p>
</section>
<section id="configuration-and-cli-blend">
<h3>Configuration and CLI “blend”<a class="headerlink" href="#configuration-and-cli-blend" title="Link to this heading">¶</a></h3>
<p>The base <code class="docutils literal notranslate"><span class="pre">Command</span></code> instantiates the class <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/parser.py">ConfigOptionParser</a>
which is in charge of the parsing process (via its parent class
<a class="reference external" href="https://docs.python.org/3/library/optparse.html#optparse.OptionParser">optparse.OptionParser</a>).
Its main addition consists of the following function:</p>
<dl class="py class">
<dt class="sig sig-object py" id="ConfigOptionParser">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">ConfigOptionParser</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">OptionParser</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ConfigOptionParser" title="Link to this definition">¶</a></dt>
<dd><dl class="py method">
<dt class="sig sig-object py" id="ConfigOptionParser.get_default_values">
<span class="sig-name descname"><span class="pre">get_default_values</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ConfigOptionParser.get_default_values" title="Link to this definition">¶</a></dt>
<dd><p>Overrides the original method to allow updating the defaults after the instantiation of the
option parser.</p>
</dd></dl>
</dd></dl>
<p>It allows overriding the default options and arguments using the <code class="docutils literal notranslate"><span class="pre">Configuration</span></code> class
(more information can be found on <a class="reference internal" href="../../topics/configuration.html#configuration"><span class="std std-ref">Configuration</span></a>) to include environment variables and
settings from configuration files.</p>
</section>
<section id="progress-bars-and-spinners">
<h3>Progress bars and spinners<a class="headerlink" href="#progress-bars-and-spinners" title="Link to this heading">¶</a></h3>
<p>There are two more modules in the <code class="docutils literal notranslate"><span class="pre">cli</span></code> subpackage in charge of showing the state of the
program.</p>
<ul>
<li><p><a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/progress_bars.py">progress_bars.py</a></p>
<p>This module contains the following function:</p>
<dl class="py function">
<dt class="sig sig-object py" id="get_download_progress_renderer">
<span class="sig-name descname"><span class="pre">get_download_progress_renderer</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#get_download_progress_renderer" title="Link to this definition">¶</a></dt>
<dd><p>It uses <a class="reference external" href="https://rich.readthedocs.io/en/stable/reference/progress.html#module-rich.progress">rich</a>
functionalities to render the download progress.</p>
</dd></dl>
<p>This function (used in <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/network/download.py">download.py</a>,
inside the <code class="docutils literal notranslate"><span class="pre">Downloader</span></code> class), allows watching the download process when running
<code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> on <em>big</em> packages.</p>
</li>
<li><p><a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/cli/spinners.py">spinner.py</a></p>
<p>The main function of this module is:</p>
<dl class="py function">
<dt class="sig sig-object py" id="open_spinner">
<span class="sig-name descname"><span class="pre">open_spinner</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#open_spinner" title="Link to this definition">¶</a></dt>
<dd><p>It yields the appropriate type of spinner, which is used in <code class="docutils literal notranslate"><span class="pre">call_subprocess</span></code>
function, inside <a class="reference external" href="https://github.com/pypa/pip/blob/main/src/pip/_internal/utils/subprocess.py">subprocess.py</a>
module, so the user can see there is a program running.</p>
</dd></dl>
</li>
<li><p>TODO: quirks / standard practices / broad ideas.
(avoiding lists in option def’n, special cased option value types,
)</p></li>
</ul>
</section>
</section>
<section id="future-refactoring-ideas">
<h2>Future Refactoring Ideas<a class="headerlink" href="#future-refactoring-ideas" title="Link to this heading">¶</a></h2>
<ul class="simple">
<li><p>Change option definition to be a more declarative, consistent, static
data-structure, replacing the current <code class="docutils literal notranslate"><span class="pre">partial(Option,</span> <span class="pre">...)</span></code> form</p></li>
<li><p>Move progress bar and spinner to a <code class="docutils literal notranslate"><span class="pre">cli.ui</span></code> subpackage</p></li>
<li><p>Move all <code class="docutils literal notranslate"><span class="pre">Command</span></code> classes into a <code class="docutils literal notranslate"><span class="pre">cli.commands</span></code> subpackage
(including base classes)</p></li>
</ul>
</section>
</section>
</article>
</div>
<footer>
<div class="related-pages">
<a class="next-page" href="upgrade-options.html">
<div class="page-info">
<div class="context">
<span>Next</span>
</div>
<div class="title">Options that control the installation process</div>
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
<a class="prev-page" href="package-finding.html">
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
<div class="page-info">
<div class="context">
<span>Previous</span>
</div>
<div class="title">Finding and choosing files (<code class="docutils literal notranslate"><span class="pre">index</span></code> and <code class="docutils literal notranslate"><span class="pre">PackageFinder</span></code>)</div>
</div>
</a>
</div>
<div class="bottom-of-page">
<div class="left-details">
<div class="copyright">
<a href="../../copyright.html">Copyright</a> © The pip developers
</div>
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
<a href="https://github.com/pradyunsg/furo">Furo</a>
</div>
<div class="right-details">
</div>
</div>
</footer>
</div>
<aside class="toc-drawer">
<div class="toc-sticky toc-scroll">
<div class="toc-title-container">
<span class="toc-title">
On this page
</span>
</div>
<div class="toc-tree-container">
<div class="toc-tree">
<ul>
<li><a class="reference internal" href="#">Command Line Interface</a><ul>
<li><a class="reference internal" href="#overview">Overview</a><ul>
<li><a class="reference internal" href="#command-structure">Command structure</a><ul>
<li><a class="reference internal" href="#Command"><code class="docutils literal notranslate"><span class="pre">Command</span></code></a><ul>
<li><a class="reference internal" href="#Command.main"><code class="docutils literal notranslate"><span class="pre">Command.main()</span></code></a></li>
<li><a class="reference internal" href="#Command.run"><code class="docutils literal notranslate"><span class="pre">Command.run()</span></code></a></li>
<li><a class="reference internal" href="#Command.add_options"><code class="docutils literal notranslate"><span class="pre">Command.add_options()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#option-definition">Option definition</a></li>
<li><a class="reference internal" href="#argument-parsing">Argument parsing</a><ul>
<li><a class="reference internal" href="#parse_command"><code class="docutils literal notranslate"><span class="pre">parse_command()</span></code></a></li>
<li><a class="reference internal" href="#create_main_parser"><code class="docutils literal notranslate"><span class="pre">create_main_parser()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#argument-access">Argument access</a></li>
<li><a class="reference internal" href="#configuration-and-cli-blend">Configuration and CLI “blend”</a><ul>
<li><a class="reference internal" href="#ConfigOptionParser"><code class="docutils literal notranslate"><span class="pre">ConfigOptionParser</span></code></a><ul>
<li><a class="reference internal" href="#ConfigOptionParser.get_default_values"><code class="docutils literal notranslate"><span class="pre">ConfigOptionParser.get_default_values()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#progress-bars-and-spinners">Progress bars and spinners</a><ul>
<li><a class="reference internal" href="#get_download_progress_renderer"><code class="docutils literal notranslate"><span class="pre">get_download_progress_renderer()</span></code></a></li>
<li><a class="reference internal" href="#open_spinner"><code class="docutils literal notranslate"><span class="pre">open_spinner()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#future-refactoring-ideas">Future Refactoring Ideas</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</aside>
</div>
</div><script src="../../_static/documentation_options.js?v=22103397"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script type="module" src="../../_static/scripts/furo.js?v=d32f1409"></script>
<script src="../../_static/clipboard.min.js?v=66b4909c"></script>
<script src="../../_static/copybutton.js?v=80126f2a"></script>
<script src="../../_static/tabs.js?v=3ee01567"></script>
</body>
</html>