CINXE.COM
Using third-party Python packages — Firefox Source Docs documentation
<!doctype html> <html class="writer-html5" lang="en" data-content_root="../"> <head> <base href="https://firefox-source-docs.mozilla.org/python/index.html"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Using third-party Python packages — Firefox Source Docs documentation</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50"> <link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094"> <link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=fd3f3429"> <link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b"> <link rel="stylesheet" type="text/css" href="../_static/custom_theme.css?v=dc5ed815"> <link rel="stylesheet" type="text/css" href="../_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css?v=0a3b3ea7"> <link rel="shortcut icon" href="../_static/firefox.ico"><!--[if lt IE 9]> <script src="../_static/js/html5shiv.min.js"></script> <![endif]--> <script src="../_static/jquery.js?v=5d32c60e"></script> <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> <script src="../_static/documentation_options.js?v=5929fcd5"></script> <script src="../_static/doctools.js?v=9a2dae69"></script> <script src="../_static/sphinx_highlight.js?v=dc90522c"></script> <script src="../_static/clipboard.min.js?v=a7894cd8"></script> <script src="../_static/copybutton.js?v=30646c52"></script> <script src="../_static/design-tabs.js?v=36754332"></script> <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html"> <link rel="search" title="Search" href="../search.html"> <link rel="next" title="Metrics" href="../metrics/index.html"> <link rel="prev" title="mozdevice — Interact with Android devices" href="../mozbase/mozdevice.html"> <meta http-equiv="X-Translated-By" content="Google"> <meta http-equiv="X-Translated-To" content="iw"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=corsproxy" data-sourceurl="https://firefox-source-docs.mozilla.org/python/index.html"></script> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/exm=corsproxy/ed=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=phishing_protection" data-phishing-protection-enabled="false" data-forms-warning-enabled="true" data-source-url="https://firefox-source-docs.mozilla.org/python/index.html"></script> <meta name="robots" content="none"> </head> <body class="wy-body-for-nav"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/exm=corsproxy,phishing_protection/ed=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=navigationui" data-environment="prod" data-proxy-url="https://firefox--source--docs-mozilla-org.translate.goog" data-proxy-full-url="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" data-source-url="https://firefox-source-docs.mozilla.org/python/index.html" data-source-language="pl" data-target-language="iw" data-display-language="en-GB" data-detected-source-language="" data-is-source-untranslated="false" data-source-untranslated-url="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://firefox-source-docs.mozilla.org/python/index.html&anno=2" data-client="tr"></script> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search"><a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="icon icon-home"> Firefox Source Docs <img src="../_static/firefox-wordmark.svg" class="logo" alt="Logo"> </a><!-- -- This code is governed by the BSD license ----> <div> <h3>Quick search</h3> <script> (function () { var cx = "dd12886298f75dbef"; var gcse = document.createElement("script"); gcse.async = true; gcse.src = "https://cse.google.com/cse.js?cx=" + cx; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(gcse, s); })(); </script><gcse:search></gcse:search> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Overview</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/glossary/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">A Glossary of Common Terms</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/overview/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">A Quick Guide to Mozilla Applications</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Getting Started</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/setup/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Getting Set Up To Work On The Firefox Codebase</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Working On Firefox</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/contributing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Working on Firefox</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/bug-mgmt/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Bug Handling</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Firefox User Guide</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/devtools-user/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox DevTools User Docs</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Source Code Documentation</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mots/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Governance</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/browser/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox Front-end</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/dom/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">DOM</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/editor/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Editor</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/layout/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Style system (CSS) & Layout</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Graphics</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/ipc/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Processes, Threads and IPC</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/devtools/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox DevTools Contributor Docs</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/toolkit/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Toolkit</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/js/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">SpiderMonkey</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/jsloader/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">JS Loader</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/geckoview/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">GeckoView</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/fenix/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Fenix</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/focus-android/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Focus for Android</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/dom/bindings/webidl/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">WebIDL</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/modules/libpref/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">libpref</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/networking/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Networking</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/remote/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Remote Protocols</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/services/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Services</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/permissions/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Permissions</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/uriloader/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">File Handling</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/widget/cocoa/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox on macOS</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/widget/windows/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox on Windows</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/toolkit/components/ml/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox AI Runtime</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/accessible/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Accessibility</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/media/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Media Playback</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/code-quality/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Code quality</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/writing-rust-code/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Writing Rust Code</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/rust-components/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Rust Components</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/profiler/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Gecko Profiler</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/performance/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Performance</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/storage/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Database bindings (SQLite, KV, …)</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/xpcom/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">XPCOM</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/nspr/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">NSPR</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/security/nss/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Network Security Services (NSS)</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/content-security/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Web Security Checks in Gecko</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">The Firefox Build System</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mach/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mach</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/try/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Pushing to Try</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/build/buildsystem/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Build System</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/taskcluster/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox CI and Taskgraph</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/moztreedocs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Managing Documentation</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mozbuild/vendor/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Vendoring Third Party Components</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Testing & Test Infrastructure</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/automated-testing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Automated Testing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/treeherder-try/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Understanding Treeherder Results</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/sheriffed-intermittents/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Sheriffed intermittent failures</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/tests-for-new-config/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Turning on Firefox tests for a new configuration</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/intermittent/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Avoiding intermittent tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/testing-policy/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Testing Policy</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/ci-configs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Configuration Changes</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/browser-chrome/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Browser chrome mochitests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/chrome-tests/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Chrome Tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/marionette/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Marionette</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/geckodriver/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">geckodriver</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/test-verification/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Test Verification</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/webrender/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">WebRender Tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/mochitest-plain/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mochitest</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/xpcshell/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">XPCShell tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/tps/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">TPS</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/web-platform/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">web-platform-tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gtest/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">GTest</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/fuzzing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Fuzzing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/sanitizer/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Sanitizer</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/perfdocs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Performance Testing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/code-coverage/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Code coverage</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing-rust-code/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Testing & Debugging Rust Code</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Releases & Updates</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mozilla Update Infrastructure</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#watershed-updates">Watershed Updates</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#desupport-updates">Desupport Updates</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/update-verify/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Update Verify</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Localization & Internationalization</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/intl/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Internationalization</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/l10n/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Localization</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Firefox and Python</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mozbase/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">mozbase</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#">Using third-party Python packages</a> <ul> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#adding-a-python-package">Adding a Python package</a> <ul> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#pip-install-the-package"><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> the package</a></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#vendoring-python-packages">Vendoring Python packages</a></li> </ul></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mach-build-native-3rd-party-dependencies">Mach/Build Native 3rd-party Dependencies</a> <ul> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mozilla-ci-builds">Mozilla CI Builds</a></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mozilla-ci-non-build-tasks">Mozilla CI non-Build Tasks</a></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#downstream-ci-builds">Downstream CI Builds</a></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#gentoo-builds">Gentoo Builds</a></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#firefox-developers">Firefox Developers</a></li> </ul></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#package-compatibility">Package compatibility</a></li> </ul></li> </ul> <p class="caption" role="heading"><span class="caption-text">Metrics Collected in Firefox</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/metrics/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Metrics</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="Mobile navigation menu"><i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox Source Docs</a> </nav> <div class="wy-nav-content"> <div class="rst-content"><!-- This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this file, - You can obtain one at http://mozilla.org/MPL/2.0/. --> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="icon icon-home" aria-label="Home"></a></li> <li class="breadcrumb-item active">Using third-party Python packages</li> <li class="wy-breadcrumbs-aside"><a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://bugzilla.mozilla.org/enter_bug.cgi?product%3DDeveloper%2BInfrastructure%26component%3DFirefox%2BSource%2BDocs%253A%2BContent%26short_desc%3DDocumentation%2Bissue%2Bon%2Bpython/index%26comment%3DURL%2B%3D%2Bhttps://firefox-source-docs.mozilla.org/python/index.html%26bug_file_loc%3Dhttps://firefox-source-docs.mozilla.org/python/index.html" rel="nofollow">Report an issue</a> / <a href="https://firefox--source--docs-mozilla-org.translate.goog/_sources/python/index.rst.txt?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" rel="nofollow"> View page source</a></li> </ul> <hr> </div> <div role="main" class="document" itemscope itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <section id="using-third-party-python-packages"> <h1>Using third-party Python packages<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#using-third-party-python-packages" title="Link to this heading"></a></h1> <p>Mach and its associated commands have a variety of 3rd-party Python dependencies. Many of these are vendored in <code class="docutils literal notranslate"><span class="pre">third_party/python</span></code>, while others are installed at runtime via <code class="docutils literal notranslate"><span class="pre">pip</span></code>.</p> <p>The dependencies of Mach itself can be found at <code class="docutils literal notranslate"><span class="pre">python/sites/mach.txt</span></code>. Mach commands may have additional dependencies which are specified at <code class="docutils literal notranslate"><span class="pre">python/sites/<site>.txt</span></code>.</p> <p>For example, the following Mach command would have its 3rd-party dependencies declared at <code class="docutils literal notranslate"><span class="pre">python/sites/foo.txt</span></code>.</p> <div class="highlight-python notranslate"> <div class="highlight"> <pre><span></span><span class="nd">@Command</span><span class="p">(</span> <span class="s2">"foo-it"</span><span class="p">,</span> <span class="n">virtualenv_name</span><span class="o">=</span><span class="s2">"foo"</span><span class="p">,</span> <span class="p">)</span> <span class="c1"># ...</span> <span class="k">def</span> <span class="nf">foo_it_command</span><span class="p">():</span> <span class="kn">import</span> <span class="nn">specific_dependency</span> </pre> </div> </div> <p>The format of <code class="docutils literal notranslate"><span class="pre"><site>.txt</span></code> files are documented further in the <a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/mach.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mach.requirements.MachEnvRequirements" title="mach.requirements.MachEnvRequirements"><code class="xref py py-class docutils literal notranslate"><span class="pre">MachEnvRequirements</span></code></a> class.</p> <section id="adding-a-python-package"> <h2>Adding a Python package<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#adding-a-python-package" title="Link to this heading"></a></h2> <p>There’s two ways of using 3rd-party Python dependencies:</p> <ul class="simple"> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#python-pip-install"><span class="std std-ref">pip install the packages</span></a>. Python dependencies with native code must be installed using <code class="docutils literal notranslate"><span class="pre">pip</span></code>. This is the recommended technique for adding new Python dependencies.</p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#python-vendor"><span class="std std-ref">Vendor the source of the Python package in-tree</span></a>. Dependencies of the Mach core logic or of building Firefox itself must be vendored.</p></li> </ul> <div class="admonition note"> <p class="admonition-title">Note</p> <p>For dependencies that meet both restrictions (dependency of Mach/build, <em>and</em> has native code), see the <a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mach-and-build-native-dependencies"><span class="std std-ref">Mach/Build Native 3rd-party Dependencies</span></a> section below.</p> </div> <section id="pip-install-the-package"><span id="python-pip-install"></span> <h3><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> the package<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#pip-install-the-package" title="Link to this heading"></a></h3> <p>To add a <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code>-d package dependency, add it to your site’s <code class="docutils literal notranslate"><span class="pre">python/sites/<site>.txt</span></code> manifest file:</p> <div class="highlight-text notranslate"> <div class="highlight"> <pre><span></span>... pypi:new-package==<version> ... </pre> </div> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Some tasks are not permitted to use external resources, and for those we can publish packages to an internal PyPI mirror. See <a class="reference external" href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://wiki.mozilla.org/ReleaseEngineering/How_To/Upload_to_internal_Pypi">how to upload to internal PyPI</a> for more details.</p> </div> </section> <section id="vendoring-python-packages"><span id="python-vendor"></span> <h3>Vendoring Python packages<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#vendoring-python-packages" title="Link to this heading"></a></h3> <p>To vendor a Python package run <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--add</span> <span class="pre"><package>~=<major>.<minor></span></code>. This will add your dependency to <code class="docutils literal notranslate"><span class="pre">third_party/python/pyproject.toml</span></code> then begin the re-vendoring process for all dependencies. The <cite>pyproject.toml</cite> is used by <code class="docutils literal notranslate"><span class="pre">uv</span></code> to create a lockfile (<code class="docutils literal notranslate"><span class="pre">uv.lock</span></code>) that ensures all the dependencies are compatible. This lockfile is then used to generate a <code class="docutils literal notranslate"><span class="pre">third_party/python/requirements.txt</span></code> which is then used by <code class="docutils literal notranslate"><span class="pre">pip</span></code> to download all dependencies into the <code class="docutils literal notranslate"><span class="pre">third_party/python</span></code> directory.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The dependency you are attempting to add may not be compatible with what’s already vendored. In this case, the lockfile generation/dependency resolution will fail with an error message along the lines of <code class="docutils literal notranslate"><span class="pre">No</span> <span class="pre">solution</span> <span class="pre">found</span> <span class="pre">when</span> <span class="pre">resolving</span> <span class="pre">dependencies:</span></code>. You may be able to get around this by pinning your dependency to a newer or older version. If that doesn’t work you can try modifying the pin(s) of the already vendored dependency(ies) that are causing the conflict(s).</p> <p>Beware that this is a rather painful process. Changing the version of an already vendored dependency may break functionality somewhere in the codebase. This means that even if you get <code class="docutils literal notranslate"><span class="pre">uv</span></code> to make a compatible lockfile, you may have caused a breakage somewhere else that <code class="docutils literal notranslate"><span class="pre">uv</span></code> cannot foresee. It is your responsibility to fix anything you break, otherwise your changes will be rejected or backed out if the issue isn’t discovered until after landing.</p> <p>If you change pins for packages to workaround issues, please add comments in the <code class="docutils literal notranslate"><span class="pre">third_party/python/pyproject.toml</span></code> for each necessary pin indicating why it’s needed and which dependency(ies) need it. Doing so will make it much easier for the next person that comes along trying to do the same thing.</p> </div> <p>After the <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span></code> completes successfully, you’ll need to add that package and any new transitive dependencies (you’ll see them added in <code class="docutils literal notranslate"><span class="pre">third_party/python/requirements.txt</span></code>) to the associated site’s dependency manifest in <code class="docutils literal notranslate"><span class="pre">python/sites/<site>.txt</span></code>:</p> <div class="highlight-text notranslate"> <div class="highlight"> <pre><span></span>... vendored:third_party/python/new-package vendored:third_party/python/new-package-dependency-foo vendored:third_party/python/new-package-dependency-bar ... </pre> </div> </div> <p>To remove a vendored package run <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--remove</span> <span class="pre"><package></span></code>. This re-creates the lockfile with that dependency removed (along with any transitive dependencies that aren’t shared) and re-vendor everything.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <ul class="simple"> <li><p>You can add or remove multiple packages at the same time: <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--add</span> <span class="pre"><package_one></span> <span class="pre">--add</span> <span class="pre"><package_two></span></code></p></li> <li><p>If desired, you can add/remove dependencies manually in the <code class="docutils literal notranslate"><span class="pre">third_party/python/pyproject.toml</span></code>. Once you’ve made your changes, just run <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span></code> without the <code class="docutils literal notranslate"><span class="pre">--add</span></code> and/or <code class="docutils literal notranslate"><span class="pre">--remove</span></code> arguments.</p></li> </ul> </div> <p>After the <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span></code> completes successfully you’ll need to remove the package and transitive dependencies from all the site manifest files (<code class="docutils literal notranslate"><span class="pre">python/sites/<site>.txt</span></code>) that used the removed package(s).</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The following policy applies to <strong>ALL</strong> vendored packages:</p> <ul class="simple"> <li><p>Vendored PyPI libraries <strong>MUST NOT</strong> be modified</p></li> <li><p>Vendored libraries <strong>SHOULD</strong> be released copies of libraries available on PyPI.</p> <ul> <li><p>When considering manually vendoring a package, discuss the situation with the <code class="docutils literal notranslate"><span class="pre">#build</span></code> team to ensure that other, more maintainable options are exhausted.</p></li> </ul></li> </ul> </div> <div class="admonition note"> <p class="admonition-title">Note</p> <p>We require that it is possible to build Firefox using only a checkout of the source, without depending on a package index. This ensures that building Firefox is deterministic and dependable, avoids packages from changing out from under us, and means we’re not affected when 3rd party services are offline. We don’t want a DoS against PyPI or a random package maintainer removing an old tarball to delay a Firefox chemspill. Therefore, packages required by Mach core logic or for building Firefox itself must be vendored.</p> </div> <p>If the vendored dependencies in the <code class="docutils literal notranslate"><span class="pre">third_party/python/pyproject.toml</span></code> are not pinned with <code class="docutils literal notranslate"><span class="pre">==</span></code>, they can be automatically upgraded. You can upgrade either a single package, or all packages.</p> <p>To upgrade an individual unpinned package just run <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--upgrade-package</span> <span class="pre"><package></span></code>. You can also update multiple specific packages at the same time: <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--upgrade-package</span> <span class="pre"><package_one></span> <span class="pre">--upgrade-package</span> <span class="pre"><package_two></span></code></p> <p>To upgrade all unpinned packages just run <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span> <span class="pre">--upgrade</span></code>.</p> <p>For both cases the process is essentially the same. <code class="docutils literal notranslate"><span class="pre">uv</span></code> is invoked and it will determine if there is/are newer versions available. If there aren’t any compatible upgrades available then nothing will be vendored. If there are, then everything will be re-vendored.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>If an upgrade adds new transitive dependencies, you will need to add them to the site(s) manifest files (the same as you need to when adding a new package).</p> </div> <p>By default <code class="docutils literal notranslate"><span class="pre">./mach</span> <span class="pre">vendor</span> <span class="pre">python</span></code> only fully runs if changes are detected in the <code class="docutils literal notranslate"><span class="pre">uv.lock</span></code> file. If you want to force the full vendor to run, just add <code class="docutils literal notranslate"><span class="pre">--force</span></code>.</p> <p>If the package contains optional native dependencies, they won’t be compiled as part of the vendored package. It is however possible to prefer the pypi version which may contain the native bits, while allowing to fallback to the vendored version:</p> <div class="highlight-text notranslate"> <div class="highlight"> <pre><span></span>... vendored-fallback:pypi-package-name:third_party/python/new-package:explanation ... </pre> </div> </div> </section> </section> <section id="mach-build-native-3rd-party-dependencies"><span id="mach-and-build-native-dependencies"></span> <h2>Mach/Build Native 3rd-party Dependencies<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mach-build-native-3rd-party-dependencies" title="Link to this heading"></a></h2> <p>There are cases where Firefox is built without being able to <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code>, but where native 3rd party Python dependencies enable optional functionality. This can’t be solved by vendoring the platform-specific libraries, as then each one would have to be stored multiple times in-tree according to how many platforms we wish to support.</p> <p>Instead, this is solved by pre-installing such native packages onto the host system in advance, then having Mach attempt to use such packages directly from the system. This feature is only viable in very specific environments, as the system Python packages have to be compatible with Mach’s vendored packages.</p> <p>To control this behaviour, the <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code> environment variable can be used:</p> <table class="docutils align-default" id="id2"> <caption> <span class="caption-text"><code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code></span><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id2" title="Link to this table"></a> </caption> <thead> <tr class="row-odd"> <th class="head"><p><code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code></p></th> <th class="head"><p>Behaviour</p></th> </tr> </thead> <tbody> <tr class="row-even"> <td><p><code class="docutils literal notranslate"><span class="pre">"pip"</span></code></p></td> <td><p>Mach will <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> all needed dependencies from PyPI at runtime into a Python virtual environment that’s reused in future Mach invocations.</p></td> </tr> <tr class="row-odd"> <td><p><code class="docutils literal notranslate"><span class="pre">"none"</span></code></p></td> <td><p>Mach will perform the build using only vendored packages. No Python virtual environment will be created for Mach.</p></td> </tr> <tr class="row-even"> <td><p><code class="docutils literal notranslate"><span class="pre">"system"</span></code></p></td> <td><p>Mach will use the host system’s Python packages as part of doing the build. This option allows the usage of native Python packages without leaning on a <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> at build-time. This is generally slower because the system Python packages have to be asserted to be compatible with Mach. Additionally, dependency lockfiles are ignored, so there’s higher risk of breakage. Finally, as with <code class="docutils literal notranslate"><span class="pre">"none"</span></code>, no Python virtualenv environment is created for Mach.</p></td> </tr> <tr class="row-odd"> <td><p><code class="docutils literal notranslate"><span class="pre"><unset></span></code></p></td> <td><p>Same behaviour as <code class="docutils literal notranslate"><span class="pre">"pip"</span></code> if <code class="docutils literal notranslate"><span class="pre">MOZ_AUTOMATION</span></code> isn’t set. Otherwise, uses the same behaviour as <code class="docutils literal notranslate"><span class="pre">"none"</span></code>.</p></td> </tr> </tbody> </table> <p>There’s a couple restrictions here:</p> <ul class="simple"> <li> <dl class="simple"> <dt> <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code> only applies to the top-level <code class="docutils literal notranslate"><span class="pre">"mach"</span></code> site, </dt> <dd> <p>the <code class="docutils literal notranslate"><span class="pre">"common"</span></code> site and the <code class="docutils literal notranslate"><span class="pre">"build"</span></code> site. All other sites will use <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> at run-time as needed.</p> </dd> </dl></li> <li><p><code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="system"</span></code> is not allowed when using any site other than <code class="docutils literal notranslate"><span class="pre">"mach"</span></code>, <code class="docutils literal notranslate"><span class="pre">"common"</span></code> or <code class="docutils literal notranslate"><span class="pre">"build"</span></code>, because:</p> <ul> <li><p>As described in <a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#package-compatibility"><span class="std std-ref">Package compatibility</span></a> below, packages used by Mach are still in scope when commands are run, and</p></li> <li><p>The host system is practically guaranteed to be incompatible with commands’ dependency lockfiles.</p></li> </ul></li> </ul> <p>The <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code> environment variable fits into the following use cases:</p> <section id="mozilla-ci-builds"> <h3>Mozilla CI Builds<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mozilla-ci-builds" title="Link to this heading"></a></h3> <p>We need access to the native packages of <code class="docutils literal notranslate"><span class="pre">zstandard</span></code> and <code class="docutils literal notranslate"><span class="pre">psutil</span></code> to extract archives and get OS information respectively. Use <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="system"</span></code>.</p> </section> <section id="mozilla-ci-non-build-tasks"> <h3>Mozilla CI non-Build Tasks<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#mozilla-ci-non-build-tasks" title="Link to this heading"></a></h3> <p>We generally don’t want to create a Mach virtual environment to avoid redundant processing, but it’s ok to <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> for specific command sites as needed, so leave <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code> unset (<code class="docutils literal notranslate"><span class="pre">MOZ_AUTOMATION</span></code> implies the default behaviour of <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none"</span></code>).</p> <p>In cases where native packages <em>are</em> needed by Mach, use <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="pip"</span></code>.</p> </section> <section id="downstream-ci-builds"> <h3>Downstream CI Builds<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#downstream-ci-builds" title="Link to this heading"></a></h3> <p>Sometimes these builds happen in sandboxed, network-less environments, and usually these builds don’t need any of the behaviour enabled by installing native Python dependencies. Use <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none"</span></code>.</p> </section> <section id="gentoo-builds"> <h3>Gentoo Builds<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#gentoo-builds" title="Link to this heading"></a></h3> <p>When installing Firefox via the package manager, Gentoo generally builds it from source rather than distributing a compiled binary artifact. Accordingly, users doing a build of Firefox in this context don’t want stray files created in <code class="docutils literal notranslate"><span class="pre">~/.mozbuild</span></code> or unnecessary <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> calls. Use <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none"</span></code>.</p> </section> <section id="firefox-developers"> <h3>Firefox Developers<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#firefox-developers" title="Link to this heading"></a></h3> <p>Leave <code class="docutils literal notranslate"><span class="pre">MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE</span></code> unset so that all Mach commands can be run, Python dependency lockfiles are respected, and optional behaviour is enabled by installing native packages.</p> </section> </section> <section id="package-compatibility"><span id="id1"></span> <h2>Package compatibility<a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#package-compatibility" title="Link to this heading"></a></h2> <p>Mach requires that all commands’ package requirements be compatible with those of Mach itself. (This is because functions and state created by Mach are still usable from within the commands, and they may still need access to their associated 3rd-party modules).</p> <p>However, it is OK for Mach commands to have package requirements which are incompatible with each other. This allows the flexibility for some Mach commands to depend on modern dependencies while other, more mature commands may still only be compatible with a much older version.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Only one version of a package may be vendored at any given time. If two Mach commands need to have conflicting packages, then at least one of them must <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> the package instead of vendoring.</p> <p>If a Mach command’s dependency conflicts with a vendored package, and that vendored package isn’t needed by Mach itself, then that vendored dependency should be moved from <code class="docutils literal notranslate"><span class="pre">python/sites/mach.txt</span></code> to its associated environment.</p> </div> </section> </section> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="Footer"><a href="https://firefox--source--docs-mozilla-org.translate.goog/mozbase/mozdevice.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="btn btn-neutral float-left" title="mozdevice — Interact with Android devices" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> <a href="https://firefox--source--docs-mozilla-org.translate.goog/metrics/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="btn btn-neutral float-right" title="Metrics" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> <hr> <div role="contentinfo"> <p></p> </div> Built with <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> <script>function gtElInit() {var lib = new google.translate.TranslateService();lib.translatePage('pl', 'iw', function () {});}</script> <script src="https://translate.google.com/translate_a/element.js?cb=gtElInit&hl=en-GB&client=wt" type="text/javascript"></script> </body> </html>