mirror of https://github.com/pypa/hatch.git
1455 lines
320 KiB
HTML
1455 lines
320 KiB
HTML
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Modern, extensible Python project management"><meta name=author content="Ofek Lev"><link href=https://hatch.pypa.io/latest/1.4/plugins/environment/reference/ rel=canonical><link rel=icon href=../../../assets/images/favicon.ico><meta name=generator content="mkdocs-1.3.1, mkdocs-material-8.3.9"><title>Reference - Hatch</title><link rel=stylesheet href=../../../assets/stylesheets/main.1d29e8d0.min.css><link rel=stylesheet href=../../../assets/stylesheets/palette.cbb835fc.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><link rel=stylesheet href=../../../assets/_mkdocstrings.css><link rel=stylesheet href=../../../assets/css/custom.css><link rel=stylesheet href=https://cdn.jsdelivr.net/gh/tonsky/FiraCode@5.2/distr/fira_code.css><script>__md_scope=new URL("../../..",location),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo> <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#environment-plugins class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <div data-md-component=outdated hidden> <aside class="md-banner md-banner--warning"> </aside> </div> <header class="md-header md-header--lifted" data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../../.. title=Hatch class="md-header__button md-logo" aria-label=Hatch data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M6.89 6.36C8.23 3.91 10 2 12 2c2 0 3.77 1.91 5.11 4.36-.85.21-1.61.71-2.11 1.41a3.712 3.712 0 0 0-5.2-.8c-.3.22-.58.49-.8.8-.5-.7-1.26-1.2-2.11-1.41M15 18.06l-3-3-3 3-3-3-1.27 1.27a7.504 7.504 0 0 0 9.11 5.43 7.529 7.529 0 0 0 5.43-5.43L18 15.06l-3 3m-6-2.12 3-3 3 3 3-3 1.5 1.5c-.13-2.31-.7-4.58-1.69-6.68-1.16.1-2.06 1.07-2.06 2.24h-1.5A2.25 2.25 0 0 0 12 7.75 2.25 2.25 0 0 0 9.75 10h-1.5c0-1.17-.9-2.14-2.06-2.24-.99 2.1-1.56 4.37-1.69 6.68l1.5-1.5 3 3Z"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> Hatch </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Reference </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_2 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3 3.19.09m3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95 2.06.05m-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31Z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_2> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5c-.84 0-1.65.15-2.39.42L12 2M3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29L3.34 7m.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14L3.36 17M20.65 7l-1.77 3.79a7.023 7.023 0 0 0-2.38-4.15l4.15.36m-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29L20.64 17M12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44L12 22Z"/></svg> </label> </form> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </label> <nav class=md-search__options aria-label=Search> <button type=reset class="md-search__icon md-icon" aria-label=Clear tabindex=-1> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg> </button> </nav> </form> <div class=md-search__output> <div class=md-search__scrollwrap data-md-scrollfix> <div class=md-search-result data-md-component=search-result> <div class=md-search-result__meta> Initializing search </div> <ol class=md-search-result__list></ol> </div> </div> </div> </div> </div> <div class=md-header__source> <a href=https://github.com/pypa/hatch title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 480 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M186.1 328.7c0 20.9-10.9 55.1-36.7 55.1s-36.7-34.2-36.7-55.1 10.9-55.1 36.7-55.1 36.7 34.2 36.7 55.1zM480 278.2c0 31.9-3.2 65.7-17.5 95-37.9 76.6-142.1 74.8-216.7 74.8-75.8 0-186.2 2.7-225.6-74.8-14.6-29-20.2-63.1-20.2-95 0-41.9 13.9-81.5 41.5-113.6-5.2-15.8-7.7-32.4-7.7-48.8 0-21.5 4.9-32.3 14.6-51.8 45.3 0 74.3 9 108.8 36 29-6.9 58.8-10 88.7-10 27 0 54.2 2.9 80.4 9.2 34-26.7 63-35.2 107.8-35.2 9.8 19.5 14.6 30.3 14.6 51.8 0 16.4-2.6 32.7-7.7 48.2 27.5 32.4 39 72.3 39 114.2zm-64.3 50.5c0-43.9-26.7-82.6-73.5-82.6-18.9 0-37 3.4-56 6-14.9 2.3-29.8 3.2-45.1 3.2-15.2 0-30.1-.9-45.1-3.2-18.7-2.6-37-6-56-6-46.8 0-73.5 38.7-73.5 82.6 0 87.8 80.4 101.3 150.4 101.3h48.2c70.3 0 150.6-13.4 150.6-101.3zm-82.6-55.1c-25.8 0-36.7 34.2-36.7 55.1s10.9 55.1 36.7 55.1 36.7-34.2 36.7-55.1-10.9-55.1-36.7-55.1z"/></svg> </div> <div class=md-source__repository> pypa/hatch </div> </a> </div> </nav> <nav class=md-tabs aria-label=Tabs data-md-component=tabs> <div class="md-tabs__inner md-grid"> <ul class=md-tabs__list> <li class=md-tabs__item> <a href=../../.. class=md-tabs__link> Home </a> </li> <li class=md-tabs__item> <a href=../../../config/metadata/ class=md-tabs__link> Configuration </a> </li> <li class=md-tabs__item> <a href=../../../cli/about/ class=md-tabs__link> CLI </a> </li> <li class=md-tabs__item> <a href=../../about/ class="md-tabs__link md-tabs__link--active"> Plugins </a> </li> <li class=md-tabs__item> <a href=../../../how-to/environment/package-indices/ class=md-tabs__link> How-to </a> </li> <li class=md-tabs__item> <a href=../../../meta/faq/ class=md-tabs__link> Meta </a> </li> </ul> </div> </nav> </header> <div class=md-container data-md-component=container> <main class=md-main data-md-component=main> <div class="md-main__inner md-grid"> <div class="md-sidebar md-sidebar--primary" data-md-component=sidebar data-md-type=navigation> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--primary md-nav--lifted" aria-label=Navigation data-md-level=0> <label class=md-nav__title for=__drawer> <a href=../../.. title=Hatch class="md-nav__button md-logo" aria-label=Hatch data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M6.89 6.36C8.23 3.91 10 2 12 2c2 0 3.77 1.91 5.11 4.36-.85.21-1.61.71-2.11 1.41a3.712 3.712 0 0 0-5.2-.8c-.3.22-.58.49-.8.8-.5-.7-1.26-1.2-2.11-1.41M15 18.06l-3-3-3 3-3-3-1.27 1.27a7.504 7.504 0 0 0 9.11 5.43 7.529 7.529 0 0 0 5.43-5.43L18 15.06l-3 3m-6-2.12 3-3 3 3 3-3 1.5 1.5c-.13-2.31-.7-4.58-1.69-6.68-1.16.1-2.06 1.07-2.06 2.24h-1.5A2.25 2.25 0 0 0 12 7.75 2.25 2.25 0 0 0 9.75 10h-1.5c0-1.17-.9-2.14-2.06-2.24-.99 2.1-1.56 4.37-1.69 6.68l1.5-1.5 3 3Z"/></svg> </a> Hatch </label> <div class=md-nav__source> <a href=https://github.com/pypa/hatch title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 480 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M186.1 328.7c0 20.9-10.9 55.1-36.7 55.1s-36.7-34.2-36.7-55.1 10.9-55.1 36.7-55.1 36.7 34.2 36.7 55.1zM480 278.2c0 31.9-3.2 65.7-17.5 95-37.9 76.6-142.1 74.8-216.7 74.8-75.8 0-186.2 2.7-225.6-74.8-14.6-29-20.2-63.1-20.2-95 0-41.9 13.9-81.5 41.5-113.6-5.2-15.8-7.7-32.4-7.7-48.8 0-21.5 4.9-32.3 14.6-51.8 45.3 0 74.3 9 108.8 36 29-6.9 58.8-10 88.7-10 27 0 54.2 2.9 80.4 9.2 34-26.7 63-35.2 107.8-35.2 9.8 19.5 14.6 30.3 14.6 51.8 0 16.4-2.6 32.7-7.7 48.2 27.5 32.4 39 72.3 39 114.2zm-64.3 50.5c0-43.9-26.7-82.6-73.5-82.6-18.9 0-37 3.4-56 6-14.9 2.3-29.8 3.2-45.1 3.2-15.2 0-30.1-.9-45.1-3.2-18.7-2.6-37-6-56-6-46.8 0-73.5 38.7-73.5 82.6 0 87.8 80.4 101.3 150.4 101.3h48.2c70.3 0 150.6-13.4 150.6-101.3zm-82.6-55.1c-25.8 0-36.7 34.2-36.7 55.1s10.9 55.1 36.7 55.1 36.7-34.2 36.7-55.1-10.9-55.1-36.7-55.1z"/></svg> </div> <div class=md-source__repository> pypa/hatch </div> </a> </div> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_1 type=checkbox id=__nav_1 checked> <label class=md-nav__link for=__nav_1> Home <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Home data-md-level=1> <label class=md-nav__title for=__nav_1> <span class="md-nav__icon md-icon"></span> Home </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../.. class=md-nav__link> About </a> </li> <li class=md-nav__item> <a href=../../../install/ class=md-nav__link> Installation </a> </li> <li class=md-nav__item> <a href=../../../intro/ class=md-nav__link> Introduction </a> </li> <li class=md-nav__item> <a href=../../../environment/ class=md-nav__link> Environments </a> </li> <li class=md-nav__item> <a href=../../../version/ class=md-nav__link> Versioning </a> </li> <li class=md-nav__item> <a href=../../../build/ class=md-nav__link> Builds </a> </li> <li class=md-nav__item> <a href=../../../publish/ class=md-nav__link> Publishing </a> </li> <li class=md-nav__item> <a href=../../../next-steps/ class=md-nav__link> Next steps </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_1_9 type=checkbox id=__nav_1_9 checked> <label class=md-nav__link for=__nav_1_9> Status <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Status data-md-level=2> <label class=md-nav__title for=__nav_1_9> <span class="md-nav__icon md-icon"></span> Status </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../history/ class=md-nav__link> History </a> </li> <li class=md-nav__item> <a href=../../../users/ class=md-nav__link> Users </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_2 type=checkbox id=__nav_2 checked> <label class=md-nav__link for=__nav_2> Configuration <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Configuration data-md-level=1> <label class=md-nav__title for=__nav_2> <span class="md-nav__icon md-icon"></span> Configuration </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../config/metadata/ class=md-nav__link> Metadata </a> </li> <li class=md-nav__item> <a href=../../../config/dependency/ class=md-nav__link> Dependencies </a> </li> <li class=md-nav__item> <a href=../../../config/build/ class=md-nav__link> Build </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_2_4 type=checkbox id=__nav_2_4 checked> <label class=md-nav__link for=__nav_2_4> Environments <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Environments data-md-level=2> <label class=md-nav__title for=__nav_2_4> <span class="md-nav__icon md-icon"></span> Environments </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../config/environment/overview/ class=md-nav__link> Overview </a> </li> <li class=md-nav__item> <a href=../../../config/environment/advanced/ class=md-nav__link> Advanced </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../../config/context/ class=md-nav__link> Context formatting </a> </li> <li class=md-nav__item> <a href=../../../config/project-templates/ class=md-nav__link> Project templates </a> </li> <li class=md-nav__item> <a href=../../../config/hatch/ class=md-nav__link> Hatch </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_3 type=checkbox id=__nav_3 checked> <label class=md-nav__link for=__nav_3> CLI <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=CLI data-md-level=1> <label class=md-nav__title for=__nav_3> <span class="md-nav__icon md-icon"></span> CLI </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../cli/about/ class=md-nav__link> About </a> </li> <li class=md-nav__item> <a href=../../../cli/reference/ class=md-nav__link> Reference </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--active md-nav__item--nested"> <input class="md-nav__toggle md-toggle" data-md-toggle=__nav_4 type=checkbox id=__nav_4 checked> <label class=md-nav__link for=__nav_4> Plugins <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Plugins data-md-level=1> <label class=md-nav__title for=__nav_4> <span class="md-nav__icon md-icon"></span> Plugins </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../about/ class=md-nav__link> About </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_2 type=checkbox id=__nav_4_2 checked> <label class=md-nav__link for=__nav_4_2> Builder <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Builder data-md-level=2> <label class=md-nav__title for=__nav_4_2> <span class="md-nav__icon md-icon"></span> Builder </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../builder/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../builder/wheel/ class=md-nav__link> Wheel </a> </li> <li class=md-nav__item> <a href=../../builder/sdist/ class=md-nav__link> Source distribution </a> </li> <li class=md-nav__item> <a href=../../builder/custom/ class=md-nav__link> Custom </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_3 type=checkbox id=__nav_4_3 checked> <label class=md-nav__link for=__nav_4_3> Build hook <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label="Build hook" data-md-level=2> <label class=md-nav__title for=__nav_4_3> <span class="md-nav__icon md-icon"></span> Build hook </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../build-hook/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../build-hook/version/ class=md-nav__link> Version </a> </li> <li class=md-nav__item> <a href=../../build-hook/custom/ class=md-nav__link> Custom </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_4 type=checkbox id=__nav_4_4 checked> <label class=md-nav__link for=__nav_4_4> Metadata hook <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label="Metadata hook" data-md-level=2> <label class=md-nav__title for=__nav_4_4> <span class="md-nav__icon md-icon"></span> Metadata hook </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../metadata-hook/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../metadata-hook/custom/ class=md-nav__link> Custom </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle" data-md-toggle=__nav_4_5 type=checkbox id=__nav_4_5 checked> <label class=md-nav__link for=__nav_4_5> Environment <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Environment data-md-level=2> <label class=md-nav__title for=__nav_4_5> <span class="md-nav__icon md-icon"></span> Environment </label> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--active"> <input class="md-nav__toggle md-toggle" data-md-toggle=toc type=checkbox id=__toc> <label class="md-nav__link md-nav__link--active" for=__toc> Reference <span class="md-nav__icon md-icon"></span> </label> <a href=./ class="md-nav__link md-nav__link--active"> Reference </a> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#known-third-party class=md-nav__link> Known third-party </a> </li> <li class=md-nav__item> <a href=#life-cycle class=md-nav__link> Life cycle </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface class=md-nav__link> EnvironmentInterface </a> <nav class=md-nav aria-label=EnvironmentInterface> <ul class=md-nav__list> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.PLUGIN_NAME class=md-nav__link> PLUGIN_NAME </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.app class=md-nav__link> app() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.root class=md-nav__link> root() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.name class=md-nav__link> name() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.data_directory class=md-nav__link> data_directory() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.config class=md-nav__link> config() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platform class=md-nav__link> platform() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.environment_dependencies class=md-nav__link> environment_dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies class=md-nav__link> dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_vars class=md-nav__link> env_vars() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_include class=md-nav__link> env_include() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_exclude class=md-nav__link> env_exclude() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platforms class=md-nav__link> platforms() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.skip_install class=md-nav__link> skip_install() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dev_mode class=md-nav__link> dev_mode() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.description class=md-nav__link> description() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.activate class=md-nav__link> activate() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.deactivate class=md-nav__link> deactivate() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.find class=md-nav__link> find() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.create class=md-nav__link> create() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.remove class=md-nav__link> remove() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.exists class=md-nav__link> exists() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project class=md-nav__link> install_project() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project_dev_mode class=md-nav__link> install_project_dev_mode() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies_in_sync class=md-nav__link> dependencies_in_sync() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.sync_dependencies class=md-nav__link> sync_dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.build_environment class=md-nav__link> build_environment() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_build_process class=md-nav__link> get_build_process() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command class=md-nav__link> construct_build_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.command_context class=md-nav__link> command_context() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.enter_shell class=md-nav__link> enter_shell() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.run_shell_command class=md-nav__link> run_shell_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.resolve_commands class=md-nav__link> resolve_commands() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars class=md-nav__link> get_env_vars() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.apply_features class=md-nav__link> apply_features() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_pip_install_command class=md-nav__link> construct_pip_install_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.join_command_args class=md-nav__link> join_command_args() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.check_compatibility class=md-nav__link> check_compatibility() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_option_types class=md-nav__link> get_option_types() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_var_option class=md-nav__link> get_env_var_option() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_context class=md-nav__link> get_context() </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../virtual/ class=md-nav__link> Virtual </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_6 type=checkbox id=__nav_4_6 checked> <label class=md-nav__link for=__nav_4_6> Environment collector <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label="Environment collector" data-md-level=2> <label class=md-nav__title for=__nav_4_6> <span class="md-nav__icon md-icon"></span> Environment collector </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../environment-collector/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../environment-collector/default/ class=md-nav__link> Default </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_7 type=checkbox id=__nav_4_7 checked> <label class=md-nav__link for=__nav_4_7> Publisher <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Publisher data-md-level=2> <label class=md-nav__title for=__nav_4_7> <span class="md-nav__icon md-icon"></span> Publisher </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../publisher/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../publisher/package-index/ class=md-nav__link> Index </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_8 type=checkbox id=__nav_4_8 checked> <label class=md-nav__link for=__nav_4_8> Version source <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label="Version source" data-md-level=2> <label class=md-nav__title for=__nav_4_8> <span class="md-nav__icon md-icon"></span> Version source </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../version-source/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../version-source/regex/ class=md-nav__link> Regex </a> </li> <li class=md-nav__item> <a href=../../version-source/code/ class=md-nav__link> Code </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_4_9 type=checkbox id=__nav_4_9 checked> <label class=md-nav__link for=__nav_4_9> Version scheme <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label="Version scheme" data-md-level=2> <label class=md-nav__title for=__nav_4_9> <span class="md-nav__icon md-icon"></span> Version scheme </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../version-scheme/reference/ class=md-nav__link> Reference </a> </li> <li class=md-nav__item> <a href=../../version-scheme/standard/ class=md-nav__link> Standard </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../utilities/ class=md-nav__link> Utilities </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_5 type=checkbox id=__nav_5 checked> <label class=md-nav__link for=__nav_5> How-to <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=How-to data-md-level=1> <label class=md-nav__title for=__nav_5> <span class="md-nav__icon md-icon"></span> How-to </label> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_5_1 type=checkbox id=__nav_5_1 checked> <label class=md-nav__link for=__nav_5_1> Environments <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Environments data-md-level=2> <label class=md-nav__title for=__nav_5_1> <span class="md-nav__icon md-icon"></span> Environments </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../how-to/environment/package-indices/ class=md-nav__link> Package indices </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_5_2 type=checkbox id=__nav_5_2 checked> <label class=md-nav__link for=__nav_5_2> Plugins <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Plugins data-md-level=2> <label class=md-nav__title for=__nav_5_2> <span class="md-nav__icon md-icon"></span> Plugins </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../how-to/plugins/testing-builds/ class=md-nav__link> Testing builds </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle=__nav_6 type=checkbox id=__nav_6 checked> <label class=md-nav__link for=__nav_6> Meta <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav aria-label=Meta data-md-level=1> <label class=md-nav__title for=__nav_6> <span class="md-nav__icon md-icon"></span> Meta </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../meta/faq/ class=md-nav__link> FAQ </a> </li> <li class=md-nav__item> <a href=../../../meta/authors/ class=md-nav__link> Authors </a> </li> </ul> </nav> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component=sidebar data-md-type=toc> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#known-third-party class=md-nav__link> Known third-party </a> </li> <li class=md-nav__item> <a href=#life-cycle class=md-nav__link> Life cycle </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface class=md-nav__link> EnvironmentInterface </a> <nav class=md-nav aria-label=EnvironmentInterface> <ul class=md-nav__list> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.PLUGIN_NAME class=md-nav__link> PLUGIN_NAME </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.app class=md-nav__link> app() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.root class=md-nav__link> root() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.name class=md-nav__link> name() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.data_directory class=md-nav__link> data_directory() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.config class=md-nav__link> config() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platform class=md-nav__link> platform() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.environment_dependencies class=md-nav__link> environment_dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies class=md-nav__link> dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_vars class=md-nav__link> env_vars() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_include class=md-nav__link> env_include() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_exclude class=md-nav__link> env_exclude() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platforms class=md-nav__link> platforms() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.skip_install class=md-nav__link> skip_install() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dev_mode class=md-nav__link> dev_mode() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.description class=md-nav__link> description() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.activate class=md-nav__link> activate() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.deactivate class=md-nav__link> deactivate() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.find class=md-nav__link> find() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.create class=md-nav__link> create() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.remove class=md-nav__link> remove() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.exists class=md-nav__link> exists() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project class=md-nav__link> install_project() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project_dev_mode class=md-nav__link> install_project_dev_mode() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies_in_sync class=md-nav__link> dependencies_in_sync() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.sync_dependencies class=md-nav__link> sync_dependencies() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.build_environment class=md-nav__link> build_environment() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_build_process class=md-nav__link> get_build_process() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command class=md-nav__link> construct_build_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.command_context class=md-nav__link> command_context() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.enter_shell class=md-nav__link> enter_shell() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.run_shell_command class=md-nav__link> run_shell_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.resolve_commands class=md-nav__link> resolve_commands() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars class=md-nav__link> get_env_vars() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.apply_features class=md-nav__link> apply_features() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_pip_install_command class=md-nav__link> construct_pip_install_command() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.join_command_args class=md-nav__link> join_command_args() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.check_compatibility class=md-nav__link> check_compatibility() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_option_types class=md-nav__link> get_option_types() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_var_option class=md-nav__link> get_env_var_option() </a> </li> <li class=md-nav__item> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_context class=md-nav__link> get_context() </a> </li> </ul> </nav> </li> </ul> </nav> </div> </div> </div> <div class=md-content data-md-component=content> <article class="md-content__inner md-typeset"> <a href=https://github.com/pypa/hatch/blob/master/docs/plugins/environment/reference.md title="Edit this page" class="md-content__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25Z"/></svg> </a> <h1 id=environment-plugins>Environment plugins<a class=headerlink href=#environment-plugins title="Permanent link">¶</a></h1> <hr> <p>See the documentation for <a href=../../../config/environment/overview/ >environment configuration</a>.</p> <h2 id=known-third-party>Known third-party<a class=headerlink href=#known-third-party title="Permanent link">¶</a></h2> <ul> <li><a href=https://github.com/OldGrumpyViking/hatch-conda>hatch-conda</a> - environments backed by Conda/Mamba</li> <li><a href=https://github.com/ofek/hatch-containers>hatch-containers</a> - environments run inside containers</li> </ul> <h2 id=life-cycle>Life cycle<a class=headerlink href=#life-cycle title="Permanent link">¶</a></h2> <p>Whenever an environment is used, the following logic is performed:</p> <div class="doc doc-object doc-function"> <div class="doc doc-contents first"> <details class=quote> <summary>Source code in <code>hatch/cli/application.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="69 "></span><span class=k>def</span> <span class=nf>prepare_environment</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>environment</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="70 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=n>environment</span><span class=o>.</span><span class=n>exists</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="71 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Creating environment: </span><span class=si>{</span><span class=n>environment</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="72 "></span> <span class=n>environment</span><span class=o>.</span><span class=n>create</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="73 "></span>
|
|
<span class=linenos data-linenos="74 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=n>environment</span><span class=o>.</span><span class=n>skip_install</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="75 "></span> <span class=k>if</span> <span class=n>environment</span><span class=o>.</span><span class=n>pre_install_commands</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="76 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Running pre-installation commands'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="77 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>run_shell_commands</span><span class=p>(</span><span class=n>environment</span><span class=p>,</span> <span class=n>environment</span><span class=o>.</span><span class=n>pre_install_commands</span><span class=p>,</span> <span class=n>source</span><span class=o>=</span><span class=s1>'pre-install'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="78 "></span>
|
|
<span class=linenos data-linenos="79 "></span> <span class=k>if</span> <span class=n>environment</span><span class=o>.</span><span class=n>dev_mode</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="80 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Installing project in development mode'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="81 "></span> <span class=n>environment</span><span class=o>.</span><span class=n>install_project_dev_mode</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="82 "></span> <span class=k>else</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="83 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Installing project'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="84 "></span> <span class=n>environment</span><span class=o>.</span><span class=n>install_project</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="85 "></span>
|
|
<span class=linenos data-linenos="86 "></span> <span class=k>if</span> <span class=n>environment</span><span class=o>.</span><span class=n>post_install_commands</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="87 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Running post-installation commands'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="88 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>run_shell_commands</span><span class=p>(</span><span class=n>environment</span><span class=p>,</span> <span class=n>environment</span><span class=o>.</span><span class=n>post_install_commands</span><span class=p>,</span> <span class=n>source</span><span class=o>=</span><span class=s1>'post-install'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="89 "></span>
|
|
<span class=linenos data-linenos="90 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Checking dependencies'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="91 "></span> <span class=n>dependencies_in_sync</span> <span class=o>=</span> <span class=n>environment</span><span class=o>.</span><span class=n>dependencies_in_sync</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="92 "></span>
|
|
<span class=linenos data-linenos="93 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=n>dependencies_in_sync</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="94 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>status_waiting</span><span class=p>(</span><span class=s1>'Syncing dependencies'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="95 "></span> <span class=n>environment</span><span class=o>.</span><span class=n>sync_dependencies</span><span class=p>()</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-class"> <h2 id=hatch.env.plugin.interface.EnvironmentInterface class="doc doc-heading"> <code>EnvironmentInterface</code> <a href=#hatch.env.plugin.interface.EnvironmentInterface class=headerlink title="Permanent link">¶</a></h2> <div class="doc doc-contents first"> <p>Example usage:</p> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> plugin.py</label><label for=hatch.env.plugin.interface.EnvironmentInterface--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hooks.py</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=kn>from</span> <span class=nn>hatch.env.plugin.interface</span> <span class=kn>import</span> <span class=n>EnvironmentInterface</span>
|
|
|
|
|
|
<span class=k>class</span> <span class=nc>SpecialEnvironment</span><span class=p>(</span><span class=n>EnvironmentInterface</span><span class=p>):</span>
|
|
<span class=n>PLUGIN_NAME</span> <span class=o>=</span> <span class=s1>'special'</span>
|
|
<span class=o>...</span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=kn>from</span> <span class=nn>hatchling.plugin</span> <span class=kn>import</span> <span class=n>hookimpl</span>
|
|
|
|
<span class=kn>from</span> <span class=nn>.plugin</span> <span class=kn>import</span> <span class=n>SpecialEnvironment</span>
|
|
|
|
|
|
<span class=nd>@hookimpl</span>
|
|
<span class=k>def</span> <span class=nf>hatch_register_environment</span><span class=p>():</span>
|
|
<span class=k>return</span> <span class=n>SpecialEnvironment</span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos=" 15 "></span><span class=k>class</span> <span class=nc>EnvironmentInterface</span><span class=p>(</span><span class=n>ABC</span><span class=p>):</span>
|
|
<span class=linenos data-linenos=" 16 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos=" 17 "></span><span class=sd> Example usage:</span>
|
|
<span class=linenos data-linenos=" 18 "></span>
|
|
<span class=linenos data-linenos=" 19 "></span><span class=sd> === ":octicons-file-code-16: plugin.py"</span>
|
|
<span class=linenos data-linenos=" 20 "></span>
|
|
<span class=linenos data-linenos=" 21 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos=" 22 "></span><span class=sd> from hatch.env.plugin.interface import EnvironmentInterface</span>
|
|
<span class=linenos data-linenos=" 23 "></span>
|
|
<span class=linenos data-linenos=" 24 "></span>
|
|
<span class=linenos data-linenos=" 25 "></span><span class=sd> class SpecialEnvironment(EnvironmentInterface):</span>
|
|
<span class=linenos data-linenos=" 26 "></span><span class=sd> PLUGIN_NAME = 'special'</span>
|
|
<span class=linenos data-linenos=" 27 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos=" 28 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos=" 29 "></span>
|
|
<span class=linenos data-linenos=" 30 "></span><span class=sd> === ":octicons-file-code-16: hooks.py"</span>
|
|
<span class=linenos data-linenos=" 31 "></span>
|
|
<span class=linenos data-linenos=" 32 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos=" 33 "></span><span class=sd> from hatchling.plugin import hookimpl</span>
|
|
<span class=linenos data-linenos=" 34 "></span>
|
|
<span class=linenos data-linenos=" 35 "></span><span class=sd> from .plugin import SpecialEnvironment</span>
|
|
<span class=linenos data-linenos=" 36 "></span>
|
|
<span class=linenos data-linenos=" 37 "></span>
|
|
<span class=linenos data-linenos=" 38 "></span><span class=sd> @hookimpl</span>
|
|
<span class=linenos data-linenos=" 39 "></span><span class=sd> def hatch_register_environment():</span>
|
|
<span class=linenos data-linenos=" 40 "></span><span class=sd> return SpecialEnvironment</span>
|
|
<span class=linenos data-linenos=" 41 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos=" 42 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos=" 43 "></span>
|
|
<span class=linenos data-linenos=" 44 "></span> <span class=n>PLUGIN_NAME</span> <span class=o>=</span> <span class=s1>''</span>
|
|
<span class=linenos data-linenos=" 45 "></span> <span class=sd>"""The name used for selection."""</span>
|
|
<span class=linenos data-linenos=" 46 "></span>
|
|
<span class=linenos data-linenos=" 47 "></span> <span class=k>def</span> <span class=fm>__init__</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>root</span><span class=p>,</span> <span class=n>metadata</span><span class=p>,</span> <span class=n>name</span><span class=p>,</span> <span class=n>config</span><span class=p>,</span> <span class=n>matrix_variables</span><span class=p>,</span> <span class=n>data_directory</span><span class=p>,</span> <span class=n>platform</span><span class=p>,</span> <span class=n>verbosity</span><span class=p>,</span> <span class=n>app</span><span class=o>=</span><span class=kc>None</span><span class=p>):</span>
|
|
<span class=linenos data-linenos=" 48 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__root</span> <span class=o>=</span> <span class=n>root</span>
|
|
<span class=linenos data-linenos=" 49 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__metadata</span> <span class=o>=</span> <span class=n>metadata</span>
|
|
<span class=linenos data-linenos=" 50 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__name</span> <span class=o>=</span> <span class=n>name</span>
|
|
<span class=linenos data-linenos=" 51 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__config</span> <span class=o>=</span> <span class=n>config</span>
|
|
<span class=linenos data-linenos=" 52 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__matrix_variables</span> <span class=o>=</span> <span class=n>matrix_variables</span>
|
|
<span class=linenos data-linenos=" 53 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__data_directory</span> <span class=o>=</span> <span class=n>data_directory</span>
|
|
<span class=linenos data-linenos=" 54 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__platform</span> <span class=o>=</span> <span class=n>platform</span>
|
|
<span class=linenos data-linenos=" 55 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__verbosity</span> <span class=o>=</span> <span class=n>verbosity</span>
|
|
<span class=linenos data-linenos=" 56 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span> <span class=o>=</span> <span class=n>app</span>
|
|
<span class=linenos data-linenos=" 57 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__context</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 58 "></span>
|
|
<span class=linenos data-linenos=" 59 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_system_python</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 60 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 61 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 62 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 63 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies_complex</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 64 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 65 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies_complex</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 66 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 67 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 68 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 69 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 70 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_features</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 71 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 72 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_scripts</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 73 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_pre_install_commands</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 74 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_post_install_commands</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos=" 75 "></span>
|
|
<span class=linenos data-linenos=" 76 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos=" 77 "></span> <span class=k>def</span> <span class=nf>matrix_variables</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos=" 78 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__matrix_variables</span>
|
|
<span class=linenos data-linenos=" 79 "></span>
|
|
<span class=linenos data-linenos=" 80 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos=" 81 "></span> <span class=k>def</span> <span class=nf>app</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos=" 82 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos=" 83 "></span><span class=sd> An instance of [Application](../utilities.md#hatchling.bridge.app.Application).</span>
|
|
<span class=linenos data-linenos=" 84 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos=" 85 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos=" 86 "></span> <span class=kn>from</span> <span class=nn>hatchling.bridge.app</span> <span class=kn>import</span> <span class=n>Application</span>
|
|
<span class=linenos data-linenos=" 87 "></span>
|
|
<span class=linenos data-linenos=" 88 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span> <span class=o>=</span> <span class=n>Application</span><span class=p>()</span><span class=o>.</span><span class=n>get_safe_application</span><span class=p>()</span>
|
|
<span class=linenos data-linenos=" 89 "></span>
|
|
<span class=linenos data-linenos=" 90 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span>
|
|
<span class=linenos data-linenos=" 91 "></span>
|
|
<span class=linenos data-linenos=" 92 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos=" 93 "></span> <span class=k>def</span> <span class=nf>context</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos=" 94 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>__context</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos=" 95 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__context</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>get_context</span><span class=p>()</span>
|
|
<span class=linenos data-linenos=" 96 "></span>
|
|
<span class=linenos data-linenos=" 97 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__context</span>
|
|
<span class=linenos data-linenos=" 98 "></span>
|
|
<span class=linenos data-linenos=" 99 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="100 "></span> <span class=k>def</span> <span class=nf>verbosity</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="101 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__verbosity</span>
|
|
<span class=linenos data-linenos="102 "></span>
|
|
<span class=linenos data-linenos="103 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="104 "></span> <span class=k>def</span> <span class=nf>root</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="105 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="106 "></span><span class=sd> The root of the project tree as a path-like object.</span>
|
|
<span class=linenos data-linenos="107 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="108 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__root</span>
|
|
<span class=linenos data-linenos="109 "></span>
|
|
<span class=linenos data-linenos="110 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="111 "></span> <span class=k>def</span> <span class=nf>metadata</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="112 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__metadata</span>
|
|
<span class=linenos data-linenos="113 "></span>
|
|
<span class=linenos data-linenos="114 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="115 "></span> <span class=k>def</span> <span class=nf>name</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="116 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="117 "></span><span class=sd> The name of the environment.</span>
|
|
<span class=linenos data-linenos="118 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="119 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__name</span>
|
|
<span class=linenos data-linenos="120 "></span>
|
|
<span class=linenos data-linenos="121 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="122 "></span> <span class=k>def</span> <span class=nf>platform</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="123 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="124 "></span><span class=sd> An instance of [Platform](../utilities.md#hatch.utils.platform.Platform).</span>
|
|
<span class=linenos data-linenos="125 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="126 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__platform</span>
|
|
<span class=linenos data-linenos="127 "></span>
|
|
<span class=linenos data-linenos="128 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="129 "></span> <span class=k>def</span> <span class=nf>data_directory</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="130 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="131 "></span><span class=sd> The [directory](../../config/hatch.md#environments) reserved exclusively for this plugin as a path-like object.</span>
|
|
<span class=linenos data-linenos="132 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="133 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__data_directory</span>
|
|
<span class=linenos data-linenos="134 "></span>
|
|
<span class=linenos data-linenos="135 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="136 "></span> <span class=k>def</span> <span class=nf>config</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="137 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="138 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="139 "></span>
|
|
<span class=linenos data-linenos="140 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="141 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="142 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="143 "></span>
|
|
<span class=linenos data-linenos="144 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="145 "></span>
|
|
<span class=linenos data-linenos="146 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="147 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="148 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="149 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="150 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__config</span>
|
|
<span class=linenos data-linenos="151 "></span>
|
|
<span class=linenos data-linenos="152 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="153 "></span> <span class=k>def</span> <span class=nf>system_python</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="154 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_system_python</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="155 "></span> <span class=n>system_python</span> <span class=o>=</span> <span class=p>(</span>
|
|
<span class=linenos data-linenos="156 "></span> <span class=n>os</span><span class=o>.</span><span class=n>environ</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=n>AppEnvVars</span><span class=o>.</span><span class=n>PYTHON</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="157 "></span> <span class=ow>or</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>modules</span><span class=o>.</span><span class=n>shutil</span><span class=o>.</span><span class=n>which</span><span class=p>(</span><span class=s1>'python'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="158 "></span> <span class=ow>or</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>modules</span><span class=o>.</span><span class=n>shutil</span><span class=o>.</span><span class=n>which</span><span class=p>(</span><span class=s1>'python3'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="159 "></span> <span class=ow>or</span> <span class=n>sys</span><span class=o>.</span><span class=n>executable</span>
|
|
<span class=linenos data-linenos="160 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="161 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=n>isabs</span><span class=p>(</span><span class=n>system_python</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="162 "></span> <span class=n>system_python</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>modules</span><span class=o>.</span><span class=n>shutil</span><span class=o>.</span><span class=n>which</span><span class=p>(</span><span class=n>system_python</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="163 "></span>
|
|
<span class=linenos data-linenos="164 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_system_python</span> <span class=o>=</span> <span class=n>system_python</span>
|
|
<span class=linenos data-linenos="165 "></span>
|
|
<span class=linenos data-linenos="166 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_system_python</span>
|
|
<span class=linenos data-linenos="167 "></span>
|
|
<span class=linenos data-linenos="168 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="169 "></span> <span class=k>def</span> <span class=nf>env_vars</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="170 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="171 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="172 "></span>
|
|
<span class=linenos data-linenos="173 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="174 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>.env-vars]</span>
|
|
<span class=linenos data-linenos="175 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="176 "></span>
|
|
<span class=linenos data-linenos="177 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="178 "></span>
|
|
<span class=linenos data-linenos="179 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="180 "></span><span class=sd> [envs.<ENV_NAME>.env-vars]</span>
|
|
<span class=linenos data-linenos="181 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="182 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="183 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="184 "></span> <span class=n>env_vars</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-vars'</span><span class=p>,</span> <span class=p>{})</span>
|
|
<span class=linenos data-linenos="185 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_vars</span><span class=p>,</span> <span class=nb>dict</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="186 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-vars` must be a mapping'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="187 "></span>
|
|
<span class=linenos data-linenos="188 "></span> <span class=k>for</span> <span class=n>key</span><span class=p>,</span> <span class=n>value</span> <span class=ow>in</span> <span class=n>env_vars</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="189 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>value</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="190 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="191 "></span> <span class=sa>f</span><span class=s1>'Environment variable `</span><span class=si>{</span><span class=n>key</span><span class=si>}</span><span class=s1>` of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-vars` must be a string'</span>
|
|
<span class=linenos data-linenos="192 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="193 "></span>
|
|
<span class=linenos data-linenos="194 "></span> <span class=n>new_env_vars</span> <span class=o>=</span> <span class=p>{}</span>
|
|
<span class=linenos data-linenos="195 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>apply_context</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>context</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="196 "></span> <span class=k>for</span> <span class=n>key</span><span class=p>,</span> <span class=n>value</span> <span class=ow>in</span> <span class=n>env_vars</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="197 "></span> <span class=n>new_env_vars</span><span class=p>[</span><span class=n>key</span><span class=p>]</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>value</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="198 "></span>
|
|
<span class=linenos data-linenos="199 "></span> <span class=n>new_env_vars</span><span class=p>[</span><span class=n>AppEnvVars</span><span class=o>.</span><span class=n>ENV_ACTIVE</span><span class=p>]</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>name</span>
|
|
<span class=linenos data-linenos="200 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span> <span class=o>=</span> <span class=n>new_env_vars</span>
|
|
<span class=linenos data-linenos="201 "></span>
|
|
<span class=linenos data-linenos="202 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span>
|
|
<span class=linenos data-linenos="203 "></span>
|
|
<span class=linenos data-linenos="204 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="205 "></span> <span class=k>def</span> <span class=nf>env_include</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="206 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="207 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="208 "></span>
|
|
<span class=linenos data-linenos="209 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="210 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="211 "></span><span class=sd> env-include = [...]</span>
|
|
<span class=linenos data-linenos="212 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="213 "></span>
|
|
<span class=linenos data-linenos="214 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="215 "></span>
|
|
<span class=linenos data-linenos="216 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="217 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="218 "></span><span class=sd> env-include = [...]</span>
|
|
<span class=linenos data-linenos="219 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="220 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="221 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="222 "></span> <span class=n>env_include</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-include'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="223 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_include</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="224 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-include` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="225 "></span>
|
|
<span class=linenos data-linenos="226 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>pattern</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>env_include</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="227 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>pattern</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="228 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Pattern #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-include` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="229 "></span>
|
|
<span class=linenos data-linenos="230 "></span> <span class=k>if</span> <span class=n>env_include</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="231 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'HATCH_BUILD_*'</span><span class=p>,</span> <span class=o>*</span><span class=n>env_include</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="232 "></span> <span class=k>else</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="233 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=o>=</span> <span class=n>env_include</span>
|
|
<span class=linenos data-linenos="234 "></span>
|
|
<span class=linenos data-linenos="235 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span>
|
|
<span class=linenos data-linenos="236 "></span>
|
|
<span class=linenos data-linenos="237 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="238 "></span> <span class=k>def</span> <span class=nf>env_exclude</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="239 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="240 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="241 "></span>
|
|
<span class=linenos data-linenos="242 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="243 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="244 "></span><span class=sd> env-exclude = [...]</span>
|
|
<span class=linenos data-linenos="245 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="246 "></span>
|
|
<span class=linenos data-linenos="247 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="248 "></span>
|
|
<span class=linenos data-linenos="249 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="250 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="251 "></span><span class=sd> env-exclude = [...]</span>
|
|
<span class=linenos data-linenos="252 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="253 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="254 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="255 "></span> <span class=n>env_exclude</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-exclude'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="256 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_exclude</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="257 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-exclude` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="258 "></span>
|
|
<span class=linenos data-linenos="259 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>pattern</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>env_exclude</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="260 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>pattern</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="261 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Pattern #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-exclude` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="262 "></span>
|
|
<span class=linenos data-linenos="263 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span> <span class=o>=</span> <span class=n>env_exclude</span>
|
|
<span class=linenos data-linenos="264 "></span>
|
|
<span class=linenos data-linenos="265 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span>
|
|
<span class=linenos data-linenos="266 "></span>
|
|
<span class=linenos data-linenos="267 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="268 "></span> <span class=k>def</span> <span class=nf>environment_dependencies_complex</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="269 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies_complex</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="270 "></span> <span class=kn>from</span> <span class=nn>packaging.requirements</span> <span class=kn>import</span> <span class=n>InvalidRequirement</span><span class=p>,</span> <span class=n>Requirement</span>
|
|
<span class=linenos data-linenos="271 "></span>
|
|
<span class=linenos data-linenos="272 "></span> <span class=n>dependencies_complex</span> <span class=o>=</span> <span class=p>[]</span>
|
|
<span class=linenos data-linenos="273 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>apply_context</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>context</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="274 "></span> <span class=k>for</span> <span class=n>option</span> <span class=ow>in</span> <span class=p>(</span><span class=s1>'dependencies'</span><span class=p>,</span> <span class=s1>'extra-dependencies'</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="275 "></span> <span class=n>dependencies</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=n>option</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="276 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>dependencies</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="277 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.</span><span class=si>{</span><span class=n>option</span><span class=si>}</span><span class=s1>` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="278 "></span>
|
|
<span class=linenos data-linenos="279 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>entry</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>dependencies</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="280 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>entry</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="281 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="282 "></span> <span class=sa>f</span><span class=s1>'Dependency #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.</span><span class=si>{</span><span class=n>option</span><span class=si>}</span><span class=s1>` must be a string'</span>
|
|
<span class=linenos data-linenos="283 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="284 "></span>
|
|
<span class=linenos data-linenos="285 "></span> <span class=k>try</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="286 "></span> <span class=n>dependencies_complex</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=n>Requirement</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>entry</span><span class=p>)))</span>
|
|
<span class=linenos data-linenos="287 "></span> <span class=k>except</span> <span class=n>InvalidRequirement</span> <span class=k>as</span> <span class=n>e</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="288 "></span> <span class=k>raise</span> <span class=ne>ValueError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="289 "></span> <span class=sa>f</span><span class=s1>'Dependency #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.</span><span class=si>{</span><span class=n>option</span><span class=si>}</span><span class=s1>` is invalid: </span><span class=si>{</span><span class=n>e</span><span class=si>}</span><span class=s1>'</span>
|
|
<span class=linenos data-linenos="290 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="291 "></span>
|
|
<span class=linenos data-linenos="292 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies_complex</span> <span class=o>=</span> <span class=n>dependencies_complex</span>
|
|
<span class=linenos data-linenos="293 "></span>
|
|
<span class=linenos data-linenos="294 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies_complex</span>
|
|
<span class=linenos data-linenos="295 "></span>
|
|
<span class=linenos data-linenos="296 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="297 "></span> <span class=k>def</span> <span class=nf>environment_dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="298 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="299 "></span><span class=sd> The list of all [environment dependencies](../../config/environment/overview.md#dependencies).</span>
|
|
<span class=linenos data-linenos="300 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="301 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="302 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span> <span class=o>=</span> <span class=p>[</span><span class=nb>str</span><span class=p>(</span><span class=n>dependency</span><span class=p>)</span> <span class=k>for</span> <span class=n>dependency</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>environment_dependencies_complex</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="303 "></span>
|
|
<span class=linenos data-linenos="304 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span>
|
|
<span class=linenos data-linenos="305 "></span>
|
|
<span class=linenos data-linenos="306 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="307 "></span> <span class=k>def</span> <span class=nf>dependencies_complex</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="308 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies_complex</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="309 "></span> <span class=n>dependencies_complex</span> <span class=o>=</span> <span class=nb>list</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>environment_dependencies_complex</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="310 "></span>
|
|
<span class=linenos data-linenos="311 "></span> <span class=c1># Ensure these are checked last to speed up initial environment creation since</span>
|
|
<span class=linenos data-linenos="312 "></span> <span class=c1># they will already be installed along with the project</span>
|
|
<span class=linenos data-linenos="313 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=bp>self</span><span class=o>.</span><span class=n>skip_install</span> <span class=ow>and</span> <span class=bp>self</span><span class=o>.</span><span class=n>dev_mode</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="314 "></span> <span class=n>dependencies_complex</span><span class=o>.</span><span class=n>extend</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>core</span><span class=o>.</span><span class=n>dependencies_complex</span><span class=o>.</span><span class=n>values</span><span class=p>())</span>
|
|
<span class=linenos data-linenos="315 "></span> <span class=k>for</span> <span class=n>feature</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>features</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="316 "></span> <span class=n>dependencies_complex</span><span class=o>.</span><span class=n>extend</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>core</span><span class=o>.</span><span class=n>optional_dependencies_complex</span><span class=p>[</span><span class=n>feature</span><span class=p>]</span><span class=o>.</span><span class=n>values</span><span class=p>())</span>
|
|
<span class=linenos data-linenos="317 "></span>
|
|
<span class=linenos data-linenos="318 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies_complex</span> <span class=o>=</span> <span class=n>dependencies_complex</span>
|
|
<span class=linenos data-linenos="319 "></span>
|
|
<span class=linenos data-linenos="320 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies_complex</span>
|
|
<span class=linenos data-linenos="321 "></span>
|
|
<span class=linenos data-linenos="322 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="323 "></span> <span class=k>def</span> <span class=nf>dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="324 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="325 "></span><span class=sd> The list of all [project dependencies](../../config/metadata.md#dependencies) (if</span>
|
|
<span class=linenos data-linenos="326 "></span><span class=sd> [installed](../../config/environment/overview.md#skip-install) and in</span>
|
|
<span class=linenos data-linenos="327 "></span><span class=sd> [dev mode](../../config/environment/overview.md#dev-mode)) and</span>
|
|
<span class=linenos data-linenos="328 "></span><span class=sd> [environment dependencies](../../config/environment/overview.md#dependencies).</span>
|
|
<span class=linenos data-linenos="329 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="330 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="331 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span> <span class=o>=</span> <span class=p>[</span><span class=nb>str</span><span class=p>(</span><span class=n>dependency</span><span class=p>)</span> <span class=k>for</span> <span class=n>dependency</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>dependencies_complex</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="332 "></span>
|
|
<span class=linenos data-linenos="333 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span>
|
|
<span class=linenos data-linenos="334 "></span>
|
|
<span class=linenos data-linenos="335 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="336 "></span> <span class=k>def</span> <span class=nf>platforms</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="337 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="338 "></span><span class=sd> All names are stored as their lower-cased version.</span>
|
|
<span class=linenos data-linenos="339 "></span>
|
|
<span class=linenos data-linenos="340 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="341 "></span>
|
|
<span class=linenos data-linenos="342 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="343 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="344 "></span><span class=sd> platforms = [...]</span>
|
|
<span class=linenos data-linenos="345 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="346 "></span>
|
|
<span class=linenos data-linenos="347 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="348 "></span>
|
|
<span class=linenos data-linenos="349 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="350 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="351 "></span><span class=sd> platforms = [...]</span>
|
|
<span class=linenos data-linenos="352 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="353 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="354 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="355 "></span> <span class=n>platforms</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'platforms'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="356 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>platforms</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="357 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.platforms` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="358 "></span>
|
|
<span class=linenos data-linenos="359 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>command</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>platforms</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="360 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="361 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Platform #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.platforms` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="362 "></span>
|
|
<span class=linenos data-linenos="363 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span> <span class=o>=</span> <span class=p>[</span><span class=n>platform</span><span class=o>.</span><span class=n>lower</span><span class=p>()</span> <span class=k>for</span> <span class=n>platform</span> <span class=ow>in</span> <span class=n>platforms</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="364 "></span>
|
|
<span class=linenos data-linenos="365 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span>
|
|
<span class=linenos data-linenos="366 "></span>
|
|
<span class=linenos data-linenos="367 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="368 "></span> <span class=k>def</span> <span class=nf>skip_install</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="369 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="370 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="371 "></span>
|
|
<span class=linenos data-linenos="372 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="373 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="374 "></span><span class=sd> skip-install = ...</span>
|
|
<span class=linenos data-linenos="375 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="376 "></span>
|
|
<span class=linenos data-linenos="377 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="378 "></span>
|
|
<span class=linenos data-linenos="379 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="380 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="381 "></span><span class=sd> skip-install = ...</span>
|
|
<span class=linenos data-linenos="382 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="383 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="384 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="385 "></span> <span class=n>skip_install</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'skip-install'</span><span class=p>,</span> <span class=ow>not</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>has_project_file</span><span class=p>())</span>
|
|
<span class=linenos data-linenos="386 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>skip_install</span><span class=p>,</span> <span class=nb>bool</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="387 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.skip-install` must be a boolean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="388 "></span>
|
|
<span class=linenos data-linenos="389 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span> <span class=o>=</span> <span class=n>skip_install</span>
|
|
<span class=linenos data-linenos="390 "></span>
|
|
<span class=linenos data-linenos="391 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span>
|
|
<span class=linenos data-linenos="392 "></span>
|
|
<span class=linenos data-linenos="393 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="394 "></span> <span class=k>def</span> <span class=nf>dev_mode</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="395 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="396 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="397 "></span>
|
|
<span class=linenos data-linenos="398 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="399 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="400 "></span><span class=sd> dev-mode = ...</span>
|
|
<span class=linenos data-linenos="401 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="402 "></span>
|
|
<span class=linenos data-linenos="403 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="404 "></span>
|
|
<span class=linenos data-linenos="405 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="406 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="407 "></span><span class=sd> dev-mode = ...</span>
|
|
<span class=linenos data-linenos="408 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="409 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="410 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="411 "></span> <span class=n>dev_mode</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'dev-mode'</span><span class=p>,</span> <span class=kc>True</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="412 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>dev_mode</span><span class=p>,</span> <span class=nb>bool</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="413 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.dev-mode` must be a boolean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="414 "></span>
|
|
<span class=linenos data-linenos="415 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span> <span class=o>=</span> <span class=n>dev_mode</span>
|
|
<span class=linenos data-linenos="416 "></span>
|
|
<span class=linenos data-linenos="417 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span>
|
|
<span class=linenos data-linenos="418 "></span>
|
|
<span class=linenos data-linenos="419 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="420 "></span> <span class=k>def</span> <span class=nf>features</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="421 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_features</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="422 "></span> <span class=kn>from</span> <span class=nn>hatchling.metadata.utils</span> <span class=kn>import</span> <span class=n>normalize_project_name</span>
|
|
<span class=linenos data-linenos="423 "></span>
|
|
<span class=linenos data-linenos="424 "></span> <span class=n>features</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'features'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="425 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>features</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="426 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.features` must be an array of strings'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="427 "></span>
|
|
<span class=linenos data-linenos="428 "></span> <span class=n>all_features</span> <span class=o>=</span> <span class=nb>set</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="429 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>feature</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>features</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="430 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>feature</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="431 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Feature #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.features` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="432 "></span> <span class=k>elif</span> <span class=ow>not</span> <span class=n>feature</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="433 "></span> <span class=k>raise</span> <span class=ne>ValueError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="434 "></span> <span class=sa>f</span><span class=s1>'Feature #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.features` cannot be an empty string'</span>
|
|
<span class=linenos data-linenos="435 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="436 "></span>
|
|
<span class=linenos data-linenos="437 "></span> <span class=n>feature</span> <span class=o>=</span> <span class=n>normalize_project_name</span><span class=p>(</span><span class=n>feature</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="438 "></span> <span class=k>if</span> <span class=n>feature</span> <span class=ow>not</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>core</span><span class=o>.</span><span class=n>optional_dependencies</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="439 "></span> <span class=k>raise</span> <span class=ne>ValueError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="440 "></span> <span class=sa>f</span><span class=s1>'Feature `</span><span class=si>{</span><span class=n>feature</span><span class=si>}</span><span class=s1>` of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.features` is not '</span>
|
|
<span class=linenos data-linenos="441 "></span> <span class=sa>f</span><span class=s1>'defined in field `project.optional-dependencies`'</span>
|
|
<span class=linenos data-linenos="442 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="443 "></span>
|
|
<span class=linenos data-linenos="444 "></span> <span class=n>all_features</span><span class=o>.</span><span class=n>add</span><span class=p>(</span><span class=n>feature</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="445 "></span>
|
|
<span class=linenos data-linenos="446 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_features</span> <span class=o>=</span> <span class=nb>sorted</span><span class=p>(</span><span class=n>all_features</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="447 "></span>
|
|
<span class=linenos data-linenos="448 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_features</span>
|
|
<span class=linenos data-linenos="449 "></span>
|
|
<span class=linenos data-linenos="450 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="451 "></span> <span class=k>def</span> <span class=nf>description</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="452 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="453 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="454 "></span>
|
|
<span class=linenos data-linenos="455 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="456 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="457 "></span><span class=sd> description = ...</span>
|
|
<span class=linenos data-linenos="458 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="459 "></span>
|
|
<span class=linenos data-linenos="460 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="461 "></span>
|
|
<span class=linenos data-linenos="462 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="463 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="464 "></span><span class=sd> description = ...</span>
|
|
<span class=linenos data-linenos="465 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="466 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="467 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="468 "></span> <span class=n>description</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'description'</span><span class=p>,</span> <span class=s1>''</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="469 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>description</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="470 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.description` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="471 "></span>
|
|
<span class=linenos data-linenos="472 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span> <span class=o>=</span> <span class=n>description</span>
|
|
<span class=linenos data-linenos="473 "></span>
|
|
<span class=linenos data-linenos="474 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span>
|
|
<span class=linenos data-linenos="475 "></span>
|
|
<span class=linenos data-linenos="476 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="477 "></span> <span class=k>def</span> <span class=nf>scripts</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="478 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_scripts</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="479 "></span> <span class=n>script_config</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'scripts'</span><span class=p>,</span> <span class=p>{})</span>
|
|
<span class=linenos data-linenos="480 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>script_config</span><span class=p>,</span> <span class=nb>dict</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="481 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.scripts` must be a table'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="482 "></span>
|
|
<span class=linenos data-linenos="483 "></span> <span class=n>config</span> <span class=o>=</span> <span class=p>{}</span>
|
|
<span class=linenos data-linenos="484 "></span>
|
|
<span class=linenos data-linenos="485 "></span> <span class=k>for</span> <span class=n>name</span><span class=p>,</span> <span class=n>data</span> <span class=ow>in</span> <span class=n>script_config</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="486 "></span> <span class=k>if</span> <span class=s1>' '</span> <span class=ow>in</span> <span class=n>name</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="487 "></span> <span class=k>raise</span> <span class=ne>ValueError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="488 "></span> <span class=sa>f</span><span class=s1>'Script name `</span><span class=si>{</span><span class=n>name</span><span class=si>}</span><span class=s1>` in field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.scripts` must not contain spaces'</span>
|
|
<span class=linenos data-linenos="489 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="490 "></span>
|
|
<span class=linenos data-linenos="491 "></span> <span class=n>commands</span> <span class=o>=</span> <span class=p>[]</span>
|
|
<span class=linenos data-linenos="492 "></span>
|
|
<span class=linenos data-linenos="493 "></span> <span class=k>if</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>data</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="494 "></span> <span class=n>commands</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=n>data</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="495 "></span> <span class=k>elif</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>data</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="496 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>command</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>data</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="497 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="498 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="499 "></span> <span class=sa>f</span><span class=s1>'Command #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> in field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.scripts.</span><span class=si>{</span><span class=n>name</span><span class=si>}</span><span class=s1>` must be a string'</span>
|
|
<span class=linenos data-linenos="500 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="501 "></span>
|
|
<span class=linenos data-linenos="502 "></span> <span class=n>commands</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=n>command</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="503 "></span> <span class=k>else</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="504 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="505 "></span> <span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.scripts.</span><span class=si>{</span><span class=n>name</span><span class=si>}</span><span class=s1>` must be a string or an array of strings'</span>
|
|
<span class=linenos data-linenos="506 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="507 "></span>
|
|
<span class=linenos data-linenos="508 "></span> <span class=n>config</span><span class=p>[</span><span class=n>name</span><span class=p>]</span> <span class=o>=</span> <span class=n>commands</span>
|
|
<span class=linenos data-linenos="509 "></span>
|
|
<span class=linenos data-linenos="510 "></span> <span class=n>seen</span> <span class=o>=</span> <span class=p>{}</span>
|
|
<span class=linenos data-linenos="511 "></span> <span class=n>active</span> <span class=o>=</span> <span class=p>[]</span>
|
|
<span class=linenos data-linenos="512 "></span> <span class=k>for</span> <span class=n>script_name</span><span class=p>,</span> <span class=n>commands</span> <span class=ow>in</span> <span class=n>config</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="513 "></span> <span class=n>commands</span><span class=p>[:]</span> <span class=o>=</span> <span class=n>expand_script_commands</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=p>,</span> <span class=n>script_name</span><span class=p>,</span> <span class=n>commands</span><span class=p>,</span> <span class=n>config</span><span class=p>,</span> <span class=n>seen</span><span class=p>,</span> <span class=n>active</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="514 "></span>
|
|
<span class=linenos data-linenos="515 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_scripts</span> <span class=o>=</span> <span class=n>config</span>
|
|
<span class=linenos data-linenos="516 "></span>
|
|
<span class=linenos data-linenos="517 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_scripts</span>
|
|
<span class=linenos data-linenos="518 "></span>
|
|
<span class=linenos data-linenos="519 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="520 "></span> <span class=k>def</span> <span class=nf>pre_install_commands</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="521 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_pre_install_commands</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="522 "></span> <span class=n>pre_install_commands</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'pre-install-commands'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="523 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>pre_install_commands</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="524 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.pre-install-commands` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="525 "></span>
|
|
<span class=linenos data-linenos="526 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>command</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>pre_install_commands</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="527 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="528 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="529 "></span> <span class=sa>f</span><span class=s1>'Command #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.pre-install-commands` must be a string'</span>
|
|
<span class=linenos data-linenos="530 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="531 "></span>
|
|
<span class=linenos data-linenos="532 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_pre_install_commands</span> <span class=o>=</span> <span class=nb>list</span><span class=p>(</span><span class=n>pre_install_commands</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="533 "></span>
|
|
<span class=linenos data-linenos="534 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_pre_install_commands</span>
|
|
<span class=linenos data-linenos="535 "></span>
|
|
<span class=linenos data-linenos="536 "></span> <span class=nd>@property</span>
|
|
<span class=linenos data-linenos="537 "></span> <span class=k>def</span> <span class=nf>post_install_commands</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="538 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_post_install_commands</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="539 "></span> <span class=n>post_install_commands</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'post-install-commands'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="540 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>post_install_commands</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="541 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.post-install-commands` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="542 "></span>
|
|
<span class=linenos data-linenos="543 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>command</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>post_install_commands</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="544 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="545 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="546 "></span> <span class=sa>f</span><span class=s1>'Command #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.post-install-commands` must be a string'</span>
|
|
<span class=linenos data-linenos="547 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="548 "></span>
|
|
<span class=linenos data-linenos="549 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_post_install_commands</span> <span class=o>=</span> <span class=nb>list</span><span class=p>(</span><span class=n>post_install_commands</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="550 "></span>
|
|
<span class=linenos data-linenos="551 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_post_install_commands</span>
|
|
<span class=linenos data-linenos="552 "></span>
|
|
<span class=linenos data-linenos="553 "></span> <span class=k>def</span> <span class=nf>activate</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="554 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="555 "></span><span class=sd> A convenience method called when using the environment as a context manager:</span>
|
|
<span class=linenos data-linenos="556 "></span>
|
|
<span class=linenos data-linenos="557 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="558 "></span><span class=sd> with environment:</span>
|
|
<span class=linenos data-linenos="559 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="560 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="561 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="562 "></span>
|
|
<span class=linenos data-linenos="563 "></span> <span class=k>def</span> <span class=nf>deactivate</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="564 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="565 "></span><span class=sd> A convenience method called after using the environment as a context manager:</span>
|
|
<span class=linenos data-linenos="566 "></span>
|
|
<span class=linenos data-linenos="567 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="568 "></span><span class=sd> with environment:</span>
|
|
<span class=linenos data-linenos="569 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="570 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="571 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="572 "></span>
|
|
<span class=linenos data-linenos="573 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="574 "></span> <span class=k>def</span> <span class=nf>find</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="575 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="576 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="577 "></span>
|
|
<span class=linenos data-linenos="578 "></span><span class=sd> This should return information about how to locate the environment.</span>
|
|
<span class=linenos data-linenos="579 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="580 "></span>
|
|
<span class=linenos data-linenos="581 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="582 "></span> <span class=k>def</span> <span class=nf>create</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="583 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="584 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="585 "></span>
|
|
<span class=linenos data-linenos="586 "></span><span class=sd> This should perform the necessary steps to set up the environment.</span>
|
|
<span class=linenos data-linenos="587 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="588 "></span>
|
|
<span class=linenos data-linenos="589 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="590 "></span> <span class=k>def</span> <span class=nf>remove</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="591 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="592 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="593 "></span>
|
|
<span class=linenos data-linenos="594 "></span><span class=sd> This should perform the necessary steps to completely remove the environment from the system and will only</span>
|
|
<span class=linenos data-linenos="595 "></span><span class=sd> be triggered manually by users with the [`env remove`](../../cli/reference.md#hatch-env-remove) or</span>
|
|
<span class=linenos data-linenos="596 "></span><span class=sd> [`env prune`](../../cli/reference.md#hatch-env-prune) commands.</span>
|
|
<span class=linenos data-linenos="597 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="598 "></span>
|
|
<span class=linenos data-linenos="599 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="600 "></span> <span class=k>def</span> <span class=nf>exists</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="601 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="602 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="603 "></span>
|
|
<span class=linenos data-linenos="604 "></span><span class=sd> This should indicate whether or not the environment has already been created.</span>
|
|
<span class=linenos data-linenos="605 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="606 "></span>
|
|
<span class=linenos data-linenos="607 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="608 "></span> <span class=k>def</span> <span class=nf>install_project</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="609 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="610 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="611 "></span>
|
|
<span class=linenos data-linenos="612 "></span><span class=sd> This should install the project in the environment.</span>
|
|
<span class=linenos data-linenos="613 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="614 "></span>
|
|
<span class=linenos data-linenos="615 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="616 "></span> <span class=k>def</span> <span class=nf>install_project_dev_mode</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="617 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="618 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="619 "></span>
|
|
<span class=linenos data-linenos="620 "></span><span class=sd> This should install the project in the environment such that the environment</span>
|
|
<span class=linenos data-linenos="621 "></span><span class=sd> always reflects the current state of the project.</span>
|
|
<span class=linenos data-linenos="622 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="623 "></span>
|
|
<span class=linenos data-linenos="624 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="625 "></span> <span class=k>def</span> <span class=nf>dependencies_in_sync</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="626 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="627 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="628 "></span>
|
|
<span class=linenos data-linenos="629 "></span><span class=sd> This should indicate whether or not the environment is compatible with the current</span>
|
|
<span class=linenos data-linenos="630 "></span><span class=sd> [dependencies](reference.md#hatch.env.plugin.interface.EnvironmentInterface.dependencies).</span>
|
|
<span class=linenos data-linenos="631 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="632 "></span>
|
|
<span class=linenos data-linenos="633 "></span> <span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="634 "></span> <span class=k>def</span> <span class=nf>sync_dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="635 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="636 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="637 "></span>
|
|
<span class=linenos data-linenos="638 "></span><span class=sd> This should install the</span>
|
|
<span class=linenos data-linenos="639 "></span><span class=sd> [dependencies](reference.md#hatch.env.plugin.interface.EnvironmentInterface.dependencies)</span>
|
|
<span class=linenos data-linenos="640 "></span><span class=sd> in the environment.</span>
|
|
<span class=linenos data-linenos="641 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="642 "></span>
|
|
<span class=linenos data-linenos="643 "></span> <span class=nd>@contextmanager</span>
|
|
<span class=linenos data-linenos="644 "></span> <span class=k>def</span> <span class=nf>build_environment</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>dependencies</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="645 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="646 "></span><span class=sd> This should set up an isolated environment in which to [`build`](../../cli/reference.md#hatch-build) the project</span>
|
|
<span class=linenos data-linenos="647 "></span><span class=sd> given a set of dependencies and must be a context manager:</span>
|
|
<span class=linenos data-linenos="648 "></span>
|
|
<span class=linenos data-linenos="649 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="650 "></span><span class=sd> with environment.build_environment([...]):</span>
|
|
<span class=linenos data-linenos="651 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="652 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="653 "></span>
|
|
<span class=linenos data-linenos="654 "></span><span class=sd> The build environment should reflect any</span>
|
|
<span class=linenos data-linenos="655 "></span><span class=sd> [environment variables](reference.md#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars)</span>
|
|
<span class=linenos data-linenos="656 "></span><span class=sd> the user defined either currently or at the time of</span>
|
|
<span class=linenos data-linenos="657 "></span><span class=sd> [creation](reference.md#hatch.env.plugin.interface.EnvironmentInterface.create).</span>
|
|
<span class=linenos data-linenos="658 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="659 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>get_env_vars</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="660 "></span> <span class=k>yield</span>
|
|
<span class=linenos data-linenos="661 "></span>
|
|
<span class=linenos data-linenos="662 "></span> <span class=k>def</span> <span class=nf>get_build_process</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>build_environment</span><span class=p>,</span> <span class=o>**</span><span class=n>kwargs</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="663 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="664 "></span><span class=sd> This will be called when the</span>
|
|
<span class=linenos data-linenos="665 "></span><span class=sd> [build environment](reference.md#hatch.env.plugin.interface.EnvironmentInterface.build_environment)</span>
|
|
<span class=linenos data-linenos="666 "></span><span class=sd> is active:</span>
|
|
<span class=linenos data-linenos="667 "></span>
|
|
<span class=linenos data-linenos="668 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="669 "></span><span class=sd> with environment.build_environment([...]) as build_environment:</span>
|
|
<span class=linenos data-linenos="670 "></span><span class=sd> build_process = environment.get_build_process(build_environment, ...)</span>
|
|
<span class=linenos data-linenos="671 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="672 "></span>
|
|
<span class=linenos data-linenos="673 "></span><span class=sd> This should return the standard library's</span>
|
|
<span class=linenos data-linenos="674 "></span><span class=sd> [subprocess.Popen](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)</span>
|
|
<span class=linenos data-linenos="675 "></span><span class=sd> with all output captured by `stdout`. The command is constructed by passing all keyword arguments to</span>
|
|
<span class=linenos data-linenos="676 "></span><span class=sd> [construct_build_command](reference.md#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command).</span>
|
|
<span class=linenos data-linenos="677 "></span>
|
|
<span class=linenos data-linenos="678 "></span><span class=sd> For an example, open the default implementation below:</span>
|
|
<span class=linenos data-linenos="679 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="680 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>capture_process</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>construct_build_command</span><span class=p>(</span><span class=o>**</span><span class=n>kwargs</span><span class=p>))</span>
|
|
<span class=linenos data-linenos="681 "></span>
|
|
<span class=linenos data-linenos="682 "></span> <span class=k>def</span> <span class=nf>enter_shell</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>name</span><span class=p>,</span> <span class=n>path</span><span class=p>,</span> <span class=n>args</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="683 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="684 "></span><span class=sd> Spawn a [shell](../../config/hatch.md#shell) within the environment.</span>
|
|
<span class=linenos data-linenos="685 "></span>
|
|
<span class=linenos data-linenos="686 "></span><span class=sd> This should either use</span>
|
|
<span class=linenos data-linenos="687 "></span><span class=sd> [command_context](reference.md#hatch.env.plugin.interface.EnvironmentInterface.command_context)</span>
|
|
<span class=linenos data-linenos="688 "></span><span class=sd> directly or provide the same guarantee.</span>
|
|
<span class=linenos data-linenos="689 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="690 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>command_context</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="691 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>exit_with_command</span><span class=p>([</span><span class=n>path</span><span class=p>,</span> <span class=o>*</span><span class=n>args</span><span class=p>])</span>
|
|
<span class=linenos data-linenos="692 "></span>
|
|
<span class=linenos data-linenos="693 "></span> <span class=k>def</span> <span class=nf>run_shell_command</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>command</span><span class=p>:</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="694 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="695 "></span><span class=sd> This should return the standard library's</span>
|
|
<span class=linenos data-linenos="696 "></span><span class=sd> [subprocess.CompletedProcess](https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess)</span>
|
|
<span class=linenos data-linenos="697 "></span><span class=sd> and will always be called when the</span>
|
|
<span class=linenos data-linenos="698 "></span><span class=sd> [command_context](reference.md#hatch.env.plugin.interface.EnvironmentInterface.command_context)</span>
|
|
<span class=linenos data-linenos="699 "></span><span class=sd> is active, with the expectation of providing the same guarantee.</span>
|
|
<span class=linenos data-linenos="700 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="701 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>run_command</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=n>shell</span><span class=o>=</span><span class=kc>True</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="702 "></span>
|
|
<span class=linenos data-linenos="703 "></span> <span class=nd>@contextmanager</span>
|
|
<span class=linenos data-linenos="704 "></span> <span class=k>def</span> <span class=nf>command_context</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="705 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="706 "></span><span class=sd> A context manager that when active should make executed shell commands reflect any</span>
|
|
<span class=linenos data-linenos="707 "></span><span class=sd> [environment variables](reference.md#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars)</span>
|
|
<span class=linenos data-linenos="708 "></span><span class=sd> the user defined either currently or at the time of</span>
|
|
<span class=linenos data-linenos="709 "></span><span class=sd> [creation](reference.md#hatch.env.plugin.interface.EnvironmentInterface.create).</span>
|
|
<span class=linenos data-linenos="710 "></span>
|
|
<span class=linenos data-linenos="711 "></span><span class=sd> For an example, open the default implementation below:</span>
|
|
<span class=linenos data-linenos="712 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="713 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>get_env_vars</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="714 "></span> <span class=k>yield</span>
|
|
<span class=linenos data-linenos="715 "></span>
|
|
<span class=linenos data-linenos="716 "></span> <span class=k>def</span> <span class=nf>resolve_commands</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>commands</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="717 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="718 "></span><span class=sd> This expands each command into one or more commands based on any</span>
|
|
<span class=linenos data-linenos="719 "></span><span class=sd> [scripts](../../config/environment/overview.md#scripts) that the user defined.</span>
|
|
<span class=linenos data-linenos="720 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="721 "></span> <span class=k>for</span> <span class=n>command</span> <span class=ow>in</span> <span class=n>commands</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="722 "></span> <span class=k>yield from</span> <span class=bp>self</span><span class=o>.</span><span class=n>expand_command</span><span class=p>(</span><span class=n>command</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="723 "></span>
|
|
<span class=linenos data-linenos="724 "></span> <span class=k>def</span> <span class=nf>expand_command</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>command</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="725 "></span> <span class=n>possible_script</span><span class=p>,</span> <span class=n>args</span><span class=p>,</span> <span class=n>ignore_exit_code</span> <span class=o>=</span> <span class=n>parse_script_command</span><span class=p>(</span><span class=n>command</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="726 "></span>
|
|
<span class=linenos data-linenos="727 "></span> <span class=c1># Indicate undefined</span>
|
|
<span class=linenos data-linenos="728 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=n>args</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="729 "></span> <span class=n>args</span> <span class=o>=</span> <span class=kc>None</span>
|
|
<span class=linenos data-linenos="730 "></span>
|
|
<span class=linenos data-linenos="731 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>apply_context</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>context</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="732 "></span> <span class=k>if</span> <span class=n>possible_script</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>scripts</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="733 "></span> <span class=k>for</span> <span class=n>cmd</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>scripts</span><span class=p>[</span><span class=n>possible_script</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="734 "></span> <span class=k>yield</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>cmd</span><span class=p>,</span> <span class=n>args</span><span class=o>=</span><span class=n>args</span><span class=p>)</span><span class=o>.</span><span class=n>strip</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="735 "></span> <span class=k>else</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="736 "></span> <span class=k>yield</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=n>args</span><span class=o>=</span><span class=n>args</span><span class=p>)</span><span class=o>.</span><span class=n>strip</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="737 "></span>
|
|
<span class=linenos data-linenos="738 "></span> <span class=k>def</span> <span class=nf>construct_build_command</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="739 "></span> <span class=bp>self</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="740 "></span> <span class=o>*</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="741 "></span> <span class=n>directory</span><span class=o>=</span><span class=kc>None</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="742 "></span> <span class=n>targets</span><span class=o>=</span><span class=p>(),</span>
|
|
<span class=linenos data-linenos="743 "></span> <span class=n>hooks_only</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="744 "></span> <span class=n>no_hooks</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="745 "></span> <span class=n>clean</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="746 "></span> <span class=n>clean_hooks_after</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="747 "></span> <span class=n>clean_only</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="748 "></span> <span class=p>):</span>
|
|
<span class=linenos data-linenos="749 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="750 "></span><span class=sd> This is the canonical way [`build`](../../cli/reference.md#hatch-build) command options are translated to</span>
|
|
<span class=linenos data-linenos="751 "></span><span class=sd> a subprocess command issued to [builders](../builder/reference.md).</span>
|
|
<span class=linenos data-linenos="752 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="753 "></span> <span class=n>command</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'python'</span><span class=p>,</span> <span class=s1>'-u'</span><span class=p>,</span> <span class=s1>'-m'</span><span class=p>,</span> <span class=s1>'hatchling'</span><span class=p>,</span> <span class=s1>'build'</span><span class=p>,</span> <span class=s1>'--app'</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="754 "></span>
|
|
<span class=linenos data-linenos="755 "></span> <span class=k>if</span> <span class=n>directory</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="756 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>((</span><span class=s1>'--directory'</span><span class=p>,</span> <span class=n>directory</span><span class=p>))</span>
|
|
<span class=linenos data-linenos="757 "></span>
|
|
<span class=linenos data-linenos="758 "></span> <span class=k>if</span> <span class=n>targets</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="759 "></span> <span class=k>for</span> <span class=n>target</span> <span class=ow>in</span> <span class=n>targets</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="760 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>((</span><span class=s1>'--target'</span><span class=p>,</span> <span class=n>target</span><span class=p>))</span>
|
|
<span class=linenos data-linenos="761 "></span>
|
|
<span class=linenos data-linenos="762 "></span> <span class=k>if</span> <span class=n>hooks_only</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="763 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--hooks-only'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="764 "></span>
|
|
<span class=linenos data-linenos="765 "></span> <span class=k>if</span> <span class=n>no_hooks</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="766 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--no-hooks'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="767 "></span>
|
|
<span class=linenos data-linenos="768 "></span> <span class=k>if</span> <span class=n>clean</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="769 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="770 "></span>
|
|
<span class=linenos data-linenos="771 "></span> <span class=k>if</span> <span class=n>clean_hooks_after</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="772 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean-hooks-after'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="773 "></span>
|
|
<span class=linenos data-linenos="774 "></span> <span class=k>if</span> <span class=n>clean_only</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="775 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean-only'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="776 "></span>
|
|
<span class=linenos data-linenos="777 "></span> <span class=k>return</span> <span class=n>command</span>
|
|
<span class=linenos data-linenos="778 "></span>
|
|
<span class=linenos data-linenos="779 "></span> <span class=k>def</span> <span class=nf>construct_pip_install_command</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="780 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="781 "></span><span class=sd> A convenience method for constructing a [`pip install`](https://pip.pypa.io/en/stable/cli/pip_install/)</span>
|
|
<span class=linenos data-linenos="782 "></span><span class=sd> command with the given verbosity. The default verbosity is set to one less than Hatch's verbosity.</span>
|
|
<span class=linenos data-linenos="783 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="784 "></span> <span class=n>command</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'python'</span><span class=p>,</span> <span class=s1>'-u'</span><span class=p>,</span> <span class=s1>'-m'</span><span class=p>,</span> <span class=s1>'pip'</span><span class=p>,</span> <span class=s1>'install'</span><span class=p>,</span> <span class=s1>'--disable-pip-version-check'</span><span class=p>,</span> <span class=s1>'--no-python-version-warning'</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="785 "></span>
|
|
<span class=linenos data-linenos="786 "></span> <span class=c1># Default to -1 verbosity</span>
|
|
<span class=linenos data-linenos="787 "></span> <span class=n>add_verbosity_flag</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>verbosity</span><span class=p>,</span> <span class=n>adjustment</span><span class=o>=-</span><span class=mi>1</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="788 "></span>
|
|
<span class=linenos data-linenos="789 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>(</span><span class=n>args</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="790 "></span> <span class=k>return</span> <span class=n>command</span>
|
|
<span class=linenos data-linenos="791 "></span>
|
|
<span class=linenos data-linenos="792 "></span> <span class=k>def</span> <span class=nf>join_command_args</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="793 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="794 "></span><span class=sd> This is used by the [`run`](../../cli/reference.md#hatch-run) command to construct the root command string</span>
|
|
<span class=linenos data-linenos="795 "></span><span class=sd> from the received arguments.</span>
|
|
<span class=linenos data-linenos="796 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="797 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>join_command_args</span><span class=p>(</span><span class=n>args</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="798 "></span>
|
|
<span class=linenos data-linenos="799 "></span> <span class=k>def</span> <span class=nf>apply_features</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>requirement</span><span class=p>:</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="800 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="801 "></span><span class=sd> A convenience method that applies any user defined [features](../../config/environment/overview.md#features)</span>
|
|
<span class=linenos data-linenos="802 "></span><span class=sd> to the given requirement.</span>
|
|
<span class=linenos data-linenos="803 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="804 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>features</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="805 "></span> <span class=n>features</span> <span class=o>=</span> <span class=s1>','</span><span class=o>.</span><span class=n>join</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>features</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="806 "></span> <span class=k>return</span> <span class=sa>f</span><span class=s1>'</span><span class=si>{</span><span class=n>requirement</span><span class=si>}</span><span class=s1>[</span><span class=si>{</span><span class=n>features</span><span class=si>}</span><span class=s1>]'</span>
|
|
<span class=linenos data-linenos="807 "></span>
|
|
<span class=linenos data-linenos="808 "></span> <span class=k>return</span> <span class=n>requirement</span>
|
|
<span class=linenos data-linenos="809 "></span>
|
|
<span class=linenos data-linenos="810 "></span> <span class=k>def</span> <span class=nf>check_compatibility</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="811 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="812 "></span><span class=sd> This raises an exception if the environment is not compatible with the user's setup. The default behavior</span>
|
|
<span class=linenos data-linenos="813 "></span><span class=sd> checks for [platform compatibility](../../config/environment/overview.md#supported-platforms)</span>
|
|
<span class=linenos data-linenos="814 "></span><span class=sd> and any method override should keep this check.</span>
|
|
<span class=linenos data-linenos="815 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="816 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>platforms</span> <span class=ow>and</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>name</span> <span class=ow>not</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>platforms</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="817 "></span> <span class=k>raise</span> <span class=ne>OSError</span><span class=p>(</span><span class=s1>'unsupported platform'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="818 "></span>
|
|
<span class=linenos data-linenos="819 "></span> <span class=k>def</span> <span class=nf>get_env_vars</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=n>EnvVars</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="820 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="821 "></span><span class=sd> Returns a mapping of environment variables that should be available to the environment. The object can</span>
|
|
<span class=linenos data-linenos="822 "></span><span class=sd> be used as a context manager to temporarily apply the environment variables to the current process.</span>
|
|
<span class=linenos data-linenos="823 "></span>
|
|
<span class=linenos data-linenos="824 "></span><span class=sd> !!! note</span>
|
|
<span class=linenos data-linenos="825 "></span><span class=sd> The environment variable `HATCH_ENV_ACTIVE` will always be set to the name of the environment.</span>
|
|
<span class=linenos data-linenos="826 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="827 "></span> <span class=k>return</span> <span class=n>EnvVars</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>env_vars</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>env_include</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>env_exclude</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="828 "></span>
|
|
<span class=linenos data-linenos="829 "></span> <span class=k>def</span> <span class=nf>get_env_var_option</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>option</span><span class=p>:</span> <span class=nb>str</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="830 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="831 "></span><span class=sd> Returns the value of the upper-cased environment variable `HATCH_ENV_TYPE_<PLUGIN_NAME>_<option>`.</span>
|
|
<span class=linenos data-linenos="832 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="833 "></span> <span class=k>return</span> <span class=n>os</span><span class=o>.</span><span class=n>environ</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=sa>f</span><span class=s1>'</span><span class=si>{</span><span class=n>AppEnvVars</span><span class=o>.</span><span class=n>ENV_OPTION_PREFIX</span><span class=si>}{</span><span class=bp>self</span><span class=o>.</span><span class=n>PLUGIN_NAME</span><span class=si>}</span><span class=s1>_</span><span class=si>{</span><span class=n>option</span><span class=si>}</span><span class=s1>'</span><span class=o>.</span><span class=n>upper</span><span class=p>(),</span> <span class=s1>''</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="834 "></span>
|
|
<span class=linenos data-linenos="835 "></span> <span class=k>def</span> <span class=nf>get_context</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="836 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="837 "></span><span class=sd> Returns a subclass of</span>
|
|
<span class=linenos data-linenos="838 "></span><span class=sd> [EnvironmentContextFormatter](../utilities.md#hatch.env.context.EnvironmentContextFormatter).</span>
|
|
<span class=linenos data-linenos="839 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="840 "></span> <span class=kn>from</span> <span class=nn>hatch.env.context</span> <span class=kn>import</span> <span class=n>EnvironmentContextFormatter</span>
|
|
<span class=linenos data-linenos="841 "></span>
|
|
<span class=linenos data-linenos="842 "></span> <span class=k>return</span> <span class=n>EnvironmentContextFormatter</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="843 "></span>
|
|
<span class=linenos data-linenos="844 "></span> <span class=nd>@staticmethod</span>
|
|
<span class=linenos data-linenos="845 "></span> <span class=k>def</span> <span class=nf>get_option_types</span><span class=p>()</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="846 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="847 "></span><span class=sd> Returns a mapping of supported options to their respective types so that they can be used by</span>
|
|
<span class=linenos data-linenos="848 "></span><span class=sd> [overrides](../../config/environment/advanced.md#option-overrides).</span>
|
|
<span class=linenos data-linenos="849 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="850 "></span> <span class=k>return</span> <span class=p>{}</span>
|
|
<span class=linenos data-linenos="851 "></span>
|
|
<span class=linenos data-linenos="852 "></span> <span class=k>def</span> <span class=fm>__enter__</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="853 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>activate</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="854 "></span> <span class=k>return</span> <span class=bp>self</span>
|
|
<span class=linenos data-linenos="855 "></span>
|
|
<span class=linenos data-linenos="856 "></span> <span class=k>def</span> <span class=fm>__exit__</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>exc_type</span><span class=p>,</span> <span class=n>exc_value</span><span class=p>,</span> <span class=n>traceback</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="857 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>deactivate</span><span class=p>()</span>
|
|
</code></pre></div> </details> <div class="doc doc-children"> <div class="doc doc-object doc-attribute"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.PLUGIN_NAME class="doc doc-heading"> <code class="highlight language-python"><span class=n>PLUGIN_NAME</span> <span class=o>=</span> <span class=s1>''</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-class-attribute"><code>class-attribute</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.PLUGIN_NAME class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The name used for selection.</p> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.app class="doc doc-heading"> <code class="highlight language-python"><span class=n>app</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.app class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>An instance of <a href=../../utilities/#hatchling.bridge.app.Application>Application</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="80 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="81 "></span><span class=k>def</span> <span class=nf>app</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="82 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="83 "></span><span class=sd> An instance of [Application](../utilities.md#hatchling.bridge.app.Application).</span>
|
|
<span class=linenos data-linenos="84 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="85 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="86 "></span> <span class=kn>from</span> <span class=nn>hatchling.bridge.app</span> <span class=kn>import</span> <span class=n>Application</span>
|
|
<span class=linenos data-linenos="87 "></span>
|
|
<span class=linenos data-linenos="88 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span> <span class=o>=</span> <span class=n>Application</span><span class=p>()</span><span class=o>.</span><span class=n>get_safe_application</span><span class=p>()</span>
|
|
<span class=linenos data-linenos="89 "></span>
|
|
<span class=linenos data-linenos="90 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__app</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.root class="doc doc-heading"> <code class="highlight language-python"><span class=n>root</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.root class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The root of the project tree as a path-like object.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="103 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="104 "></span><span class=k>def</span> <span class=nf>root</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="105 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="106 "></span><span class=sd> The root of the project tree as a path-like object.</span>
|
|
<span class=linenos data-linenos="107 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="108 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__root</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.name class="doc doc-heading"> <code class="highlight language-python"><span class=n>name</span><span class=p>()</span> <span class=o>-></span> <span class=nb>str</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.name class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The name of the environment.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="114 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="115 "></span><span class=k>def</span> <span class=nf>name</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="116 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="117 "></span><span class=sd> The name of the environment.</span>
|
|
<span class=linenos data-linenos="118 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="119 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__name</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.data_directory class="doc doc-heading"> <code class="highlight language-python"><span class=n>data_directory</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.data_directory class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The <a href=../../../config/hatch/#environments>directory</a> reserved exclusively for this plugin as a path-like object.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="128 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="129 "></span><span class=k>def</span> <span class=nf>data_directory</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="130 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="131 "></span><span class=sd> The [directory](../../config/hatch.md#environments) reserved exclusively for this plugin as a path-like object.</span>
|
|
<span class=linenos data-linenos="132 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="133 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__data_directory</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.config class="doc doc-heading"> <code class="highlight language-python"><span class=n>config</span><span class=p>()</span> <span class=o>-></span> <span class=nb>dict</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.config class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.config--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="135 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="136 "></span><span class=k>def</span> <span class=nf>config</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="137 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="138 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="139 "></span>
|
|
<span class=linenos data-linenos="140 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="141 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="142 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="143 "></span>
|
|
<span class=linenos data-linenos="144 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="145 "></span>
|
|
<span class=linenos data-linenos="146 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="147 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="148 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="149 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="150 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__config</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.platform class="doc doc-heading"> <code class="highlight language-python"><span class=n>platform</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platform class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>An instance of <a href=../../utilities/#hatch.utils.platform.Platform>Platform</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="121 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="122 "></span><span class=k>def</span> <span class=nf>platform</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="123 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="124 "></span><span class=sd> An instance of [Platform](../utilities.md#hatch.utils.platform.Platform).</span>
|
|
<span class=linenos data-linenos="125 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="126 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>__platform</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.environment_dependencies class="doc doc-heading"> <code class="highlight language-python"><span class=n>environment_dependencies</span><span class=p>()</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.environment_dependencies class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The list of all <a href=../../../config/environment/overview/#dependencies>environment dependencies</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="296 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="297 "></span><span class=k>def</span> <span class=nf>environment_dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="298 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="299 "></span><span class=sd> The list of all [environment dependencies](../../config/environment/overview.md#dependencies).</span>
|
|
<span class=linenos data-linenos="300 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="301 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="302 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span> <span class=o>=</span> <span class=p>[</span><span class=nb>str</span><span class=p>(</span><span class=n>dependency</span><span class=p>)</span> <span class=k>for</span> <span class=n>dependency</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>environment_dependencies_complex</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="303 "></span>
|
|
<span class=linenos data-linenos="304 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_environment_dependencies</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.dependencies class="doc doc-heading"> <code class="highlight language-python"><span class=n>dependencies</span><span class=p>()</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>The list of all <a href=../../../config/metadata/#dependencies>project dependencies</a> (if <a href=../../../config/environment/overview/#skip-install>installed</a> and in <a href=../../../config/environment/overview/#dev-mode>dev mode</a>) and <a href=../../../config/environment/overview/#dependencies>environment dependencies</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="322 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="323 "></span><span class=k>def</span> <span class=nf>dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="324 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="325 "></span><span class=sd> The list of all [project dependencies](../../config/metadata.md#dependencies) (if</span>
|
|
<span class=linenos data-linenos="326 "></span><span class=sd> [installed](../../config/environment/overview.md#skip-install) and in</span>
|
|
<span class=linenos data-linenos="327 "></span><span class=sd> [dev mode](../../config/environment/overview.md#dev-mode)) and</span>
|
|
<span class=linenos data-linenos="328 "></span><span class=sd> [environment dependencies](../../config/environment/overview.md#dependencies).</span>
|
|
<span class=linenos data-linenos="329 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="330 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="331 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span> <span class=o>=</span> <span class=p>[</span><span class=nb>str</span><span class=p>(</span><span class=n>dependency</span><span class=p>)</span> <span class=k>for</span> <span class=n>dependency</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>dependencies_complex</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="332 "></span>
|
|
<span class=linenos data-linenos="333 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dependencies</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.env_vars class="doc doc-heading"> <code class="highlight language-python"><span class=n>env_vars</span><span class=p>()</span> <span class=o>-></span> <span class=nb>dict</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_vars class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.env_vars--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>.env-vars]</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>.env-vars]</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="168 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="169 "></span><span class=k>def</span> <span class=nf>env_vars</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="170 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="171 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="172 "></span>
|
|
<span class=linenos data-linenos="173 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="174 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>.env-vars]</span>
|
|
<span class=linenos data-linenos="175 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="176 "></span>
|
|
<span class=linenos data-linenos="177 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="178 "></span>
|
|
<span class=linenos data-linenos="179 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="180 "></span><span class=sd> [envs.<ENV_NAME>.env-vars]</span>
|
|
<span class=linenos data-linenos="181 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="182 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="183 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="184 "></span> <span class=n>env_vars</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-vars'</span><span class=p>,</span> <span class=p>{})</span>
|
|
<span class=linenos data-linenos="185 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_vars</span><span class=p>,</span> <span class=nb>dict</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="186 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-vars` must be a mapping'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="187 "></span>
|
|
<span class=linenos data-linenos="188 "></span> <span class=k>for</span> <span class=n>key</span><span class=p>,</span> <span class=n>value</span> <span class=ow>in</span> <span class=n>env_vars</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="189 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>value</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="190 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="191 "></span> <span class=sa>f</span><span class=s1>'Environment variable `</span><span class=si>{</span><span class=n>key</span><span class=si>}</span><span class=s1>` of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-vars` must be a string'</span>
|
|
<span class=linenos data-linenos="192 "></span> <span class=p>)</span>
|
|
<span class=linenos data-linenos="193 "></span>
|
|
<span class=linenos data-linenos="194 "></span> <span class=n>new_env_vars</span> <span class=o>=</span> <span class=p>{}</span>
|
|
<span class=linenos data-linenos="195 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>apply_context</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>context</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="196 "></span> <span class=k>for</span> <span class=n>key</span><span class=p>,</span> <span class=n>value</span> <span class=ow>in</span> <span class=n>env_vars</span><span class=o>.</span><span class=n>items</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="197 "></span> <span class=n>new_env_vars</span><span class=p>[</span><span class=n>key</span><span class=p>]</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>context</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>value</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="198 "></span>
|
|
<span class=linenos data-linenos="199 "></span> <span class=n>new_env_vars</span><span class=p>[</span><span class=n>AppEnvVars</span><span class=o>.</span><span class=n>ENV_ACTIVE</span><span class=p>]</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>name</span>
|
|
<span class=linenos data-linenos="200 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span> <span class=o>=</span> <span class=n>new_env_vars</span>
|
|
<span class=linenos data-linenos="201 "></span>
|
|
<span class=linenos data-linenos="202 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_vars</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.env_include class="doc doc-heading"> <code class="highlight language-python"><span class=n>env_include</span><span class=p>()</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_include class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.env_include--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>env-include</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>env-include</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="204 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="205 "></span><span class=k>def</span> <span class=nf>env_include</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="206 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="207 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="208 "></span>
|
|
<span class=linenos data-linenos="209 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="210 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="211 "></span><span class=sd> env-include = [...]</span>
|
|
<span class=linenos data-linenos="212 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="213 "></span>
|
|
<span class=linenos data-linenos="214 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="215 "></span>
|
|
<span class=linenos data-linenos="216 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="217 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="218 "></span><span class=sd> env-include = [...]</span>
|
|
<span class=linenos data-linenos="219 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="220 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="221 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="222 "></span> <span class=n>env_include</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-include'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="223 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_include</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="224 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-include` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="225 "></span>
|
|
<span class=linenos data-linenos="226 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>pattern</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>env_include</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="227 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>pattern</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="228 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Pattern #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-include` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="229 "></span>
|
|
<span class=linenos data-linenos="230 "></span> <span class=k>if</span> <span class=n>env_include</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="231 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'HATCH_BUILD_*'</span><span class=p>,</span> <span class=o>*</span><span class=n>env_include</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="232 "></span> <span class=k>else</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="233 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span> <span class=o>=</span> <span class=n>env_include</span>
|
|
<span class=linenos data-linenos="234 "></span>
|
|
<span class=linenos data-linenos="235 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_include</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.env_exclude class="doc doc-heading"> <code class="highlight language-python"><span class=n>env_exclude</span><span class=p>()</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.env_exclude class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.env_exclude--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>env-exclude</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>env-exclude</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="237 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="238 "></span><span class=k>def</span> <span class=nf>env_exclude</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="239 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="240 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="241 "></span>
|
|
<span class=linenos data-linenos="242 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="243 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="244 "></span><span class=sd> env-exclude = [...]</span>
|
|
<span class=linenos data-linenos="245 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="246 "></span>
|
|
<span class=linenos data-linenos="247 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="248 "></span>
|
|
<span class=linenos data-linenos="249 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="250 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="251 "></span><span class=sd> env-exclude = [...]</span>
|
|
<span class=linenos data-linenos="252 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="253 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="254 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="255 "></span> <span class=n>env_exclude</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'env-exclude'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="256 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>env_exclude</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="257 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-exclude` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="258 "></span>
|
|
<span class=linenos data-linenos="259 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>pattern</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>env_exclude</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="260 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>pattern</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="261 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Pattern #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.env-exclude` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="262 "></span>
|
|
<span class=linenos data-linenos="263 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span> <span class=o>=</span> <span class=n>env_exclude</span>
|
|
<span class=linenos data-linenos="264 "></span>
|
|
<span class=linenos data-linenos="265 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_env_exclude</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.platforms class="doc doc-heading"> <code class="highlight language-python"><span class=n>platforms</span><span class=p>()</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.platforms class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>All names are stored as their lower-cased version.</p> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.platforms--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>platforms</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>platforms</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>[...]</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="335 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="336 "></span><span class=k>def</span> <span class=nf>platforms</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]:</span>
|
|
<span class=linenos data-linenos="337 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="338 "></span><span class=sd> All names are stored as their lower-cased version.</span>
|
|
<span class=linenos data-linenos="339 "></span>
|
|
<span class=linenos data-linenos="340 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="341 "></span>
|
|
<span class=linenos data-linenos="342 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="343 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="344 "></span><span class=sd> platforms = [...]</span>
|
|
<span class=linenos data-linenos="345 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="346 "></span>
|
|
<span class=linenos data-linenos="347 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="348 "></span>
|
|
<span class=linenos data-linenos="349 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="350 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="351 "></span><span class=sd> platforms = [...]</span>
|
|
<span class=linenos data-linenos="352 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="353 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="354 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="355 "></span> <span class=n>platforms</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'platforms'</span><span class=p>,</span> <span class=p>[])</span>
|
|
<span class=linenos data-linenos="356 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>platforms</span><span class=p>,</span> <span class=nb>list</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="357 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.platforms` must be an array'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="358 "></span>
|
|
<span class=linenos data-linenos="359 "></span> <span class=k>for</span> <span class=n>i</span><span class=p>,</span> <span class=n>command</span> <span class=ow>in</span> <span class=nb>enumerate</span><span class=p>(</span><span class=n>platforms</span><span class=p>,</span> <span class=mi>1</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="360 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="361 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Platform #</span><span class=si>{</span><span class=n>i</span><span class=si>}</span><span class=s1> of field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.platforms` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="362 "></span>
|
|
<span class=linenos data-linenos="363 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span> <span class=o>=</span> <span class=p>[</span><span class=n>platform</span><span class=o>.</span><span class=n>lower</span><span class=p>()</span> <span class=k>for</span> <span class=n>platform</span> <span class=ow>in</span> <span class=n>platforms</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="364 "></span>
|
|
<span class=linenos data-linenos="365 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_platforms</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.skip_install class="doc doc-heading"> <code class="highlight language-python"><span class=n>skip_install</span><span class=p>()</span> <span class=o>-></span> <span class=nb>bool</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.skip_install class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.skip_install--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>skip-install</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>skip-install</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="367 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="368 "></span><span class=k>def</span> <span class=nf>skip_install</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="369 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="370 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="371 "></span>
|
|
<span class=linenos data-linenos="372 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="373 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="374 "></span><span class=sd> skip-install = ...</span>
|
|
<span class=linenos data-linenos="375 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="376 "></span>
|
|
<span class=linenos data-linenos="377 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="378 "></span>
|
|
<span class=linenos data-linenos="379 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="380 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="381 "></span><span class=sd> skip-install = ...</span>
|
|
<span class=linenos data-linenos="382 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="383 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="384 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="385 "></span> <span class=n>skip_install</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'skip-install'</span><span class=p>,</span> <span class=ow>not</span> <span class=bp>self</span><span class=o>.</span><span class=n>metadata</span><span class=o>.</span><span class=n>has_project_file</span><span class=p>())</span>
|
|
<span class=linenos data-linenos="386 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>skip_install</span><span class=p>,</span> <span class=nb>bool</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="387 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.skip-install` must be a boolean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="388 "></span>
|
|
<span class=linenos data-linenos="389 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span> <span class=o>=</span> <span class=n>skip_install</span>
|
|
<span class=linenos data-linenos="390 "></span>
|
|
<span class=linenos data-linenos="391 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_skip_install</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.dev_mode class="doc doc-heading"> <code class="highlight language-python"><span class=n>dev_mode</span><span class=p>()</span> <span class=o>-></span> <span class=nb>bool</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dev_mode class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.dev_mode--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>dev-mode</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>dev-mode</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="393 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="394 "></span><span class=k>def</span> <span class=nf>dev_mode</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="395 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="396 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="397 "></span>
|
|
<span class=linenos data-linenos="398 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="399 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="400 "></span><span class=sd> dev-mode = ...</span>
|
|
<span class=linenos data-linenos="401 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="402 "></span>
|
|
<span class=linenos data-linenos="403 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="404 "></span>
|
|
<span class=linenos data-linenos="405 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="406 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="407 "></span><span class=sd> dev-mode = ...</span>
|
|
<span class=linenos data-linenos="408 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="409 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="410 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="411 "></span> <span class=n>dev_mode</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'dev-mode'</span><span class=p>,</span> <span class=kc>True</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="412 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>dev_mode</span><span class=p>,</span> <span class=nb>bool</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="413 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.dev-mode` must be a boolean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="414 "></span>
|
|
<span class=linenos data-linenos="415 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span> <span class=o>=</span> <span class=n>dev_mode</span>
|
|
<span class=linenos data-linenos="416 "></span>
|
|
<span class=linenos data-linenos="417 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_dev_mode</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.description class="doc doc-heading"> <code class="highlight language-python"><span class=n>description</span><span class=p>()</span> <span class=o>-></span> <span class=nb>str</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-property"><code>property</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.description class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <div class="tabbed-set tabbed-alternate" data-tabs=1:2><input checked=checked id=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1_1 name=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1 type=radio><input id=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1_2 name=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1 type=radio><div class=tabbed-labels><label for=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1_1><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> pyproject.toml</label><label for=hatch.env.plugin.interface.EnvironmentInterface.description--__tabbed_1_2><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 16 16"><path fill-rule=evenodd d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0v-2.5zm7.5-.188V4.25c0 .138.112.25.25.25h2.688a.252.252 0 0 0-.011-.013l-2.914-2.914a.272.272 0 0 0-.013-.011zM5.72 6.72a.75.75 0 0 0 0 1.06l1.47 1.47-1.47 1.47a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0zM3.28 7.78a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 0 0 1.06-1.06L1.81 9.25l1.47-1.47z"/></svg></span> hatch.toml</label></div> <div class=tabbed-content> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[tool.hatch.envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>description</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> <div class=tabbed-block> <div class=highlight><pre><span></span><code><span class=k>[envs.<ENV_NAME>]</span><span class=w></span>
|
|
<span class=n>description</span><span class=w> </span><span class=o>=</span><span class=w> </span><span class=p>...</span><span class=w></span>
|
|
</code></pre></div> </div> </div> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="450 "></span><span class=nd>@property</span>
|
|
<span class=linenos data-linenos="451 "></span><span class=k>def</span> <span class=nf>description</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="452 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="453 "></span><span class=sd> === ":octicons-file-code-16: pyproject.toml"</span>
|
|
<span class=linenos data-linenos="454 "></span>
|
|
<span class=linenos data-linenos="455 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="456 "></span><span class=sd> [tool.hatch.envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="457 "></span><span class=sd> description = ...</span>
|
|
<span class=linenos data-linenos="458 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="459 "></span>
|
|
<span class=linenos data-linenos="460 "></span><span class=sd> === ":octicons-file-code-16: hatch.toml"</span>
|
|
<span class=linenos data-linenos="461 "></span>
|
|
<span class=linenos data-linenos="462 "></span><span class=sd> ```toml</span>
|
|
<span class=linenos data-linenos="463 "></span><span class=sd> [envs.<ENV_NAME>]</span>
|
|
<span class=linenos data-linenos="464 "></span><span class=sd> description = ...</span>
|
|
<span class=linenos data-linenos="465 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="466 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="467 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span> <span class=ow>is</span> <span class=kc>None</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="468 "></span> <span class=n>description</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>config</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=s1>'description'</span><span class=p>,</span> <span class=s1>''</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="469 "></span> <span class=k>if</span> <span class=ow>not</span> <span class=nb>isinstance</span><span class=p>(</span><span class=n>description</span><span class=p>,</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="470 "></span> <span class=k>raise</span> <span class=ne>TypeError</span><span class=p>(</span><span class=sa>f</span><span class=s1>'Field `tool.hatch.envs.</span><span class=si>{</span><span class=bp>self</span><span class=o>.</span><span class=n>name</span><span class=si>}</span><span class=s1>.description` must be a string'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="471 "></span>
|
|
<span class=linenos data-linenos="472 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span> <span class=o>=</span> <span class=n>description</span>
|
|
<span class=linenos data-linenos="473 "></span>
|
|
<span class=linenos data-linenos="474 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>_description</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.activate class="doc doc-heading"> <code class="highlight language-python"><span class=n>activate</span><span class=p>()</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.activate class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>A convenience method called when using the environment as a context manager:</p> <div class=highlight><pre><span></span><code><span class=k>with</span> <span class=n>environment</span><span class=p>:</span>
|
|
<span class=o>...</span>
|
|
</code></pre></div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="553 "></span><span class=k>def</span> <span class=nf>activate</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="554 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="555 "></span><span class=sd> A convenience method called when using the environment as a context manager:</span>
|
|
<span class=linenos data-linenos="556 "></span>
|
|
<span class=linenos data-linenos="557 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="558 "></span><span class=sd> with environment:</span>
|
|
<span class=linenos data-linenos="559 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="560 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="561 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.deactivate class="doc doc-heading"> <code class="highlight language-python"><span class=n>deactivate</span><span class=p>()</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.deactivate class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>A convenience method called after using the environment as a context manager:</p> <div class=highlight><pre><span></span><code><span class=k>with</span> <span class=n>environment</span><span class=p>:</span>
|
|
<span class=o>...</span>
|
|
</code></pre></div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="563 "></span><span class=k>def</span> <span class=nf>deactivate</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="564 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="565 "></span><span class=sd> A convenience method called after using the environment as a context manager:</span>
|
|
<span class=linenos data-linenos="566 "></span>
|
|
<span class=linenos data-linenos="567 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="568 "></span><span class=sd> with environment:</span>
|
|
<span class=linenos data-linenos="569 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="570 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="571 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.find class="doc doc-heading"> <code class="highlight language-python"><span class=n>find</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.find class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should return information about how to locate the environment.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="573 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="574 "></span><span class=k>def</span> <span class=nf>find</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="575 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="576 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="577 "></span>
|
|
<span class=linenos data-linenos="578 "></span><span class=sd> This should return information about how to locate the environment.</span>
|
|
<span class=linenos data-linenos="579 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.create class="doc doc-heading"> <code class="highlight language-python"><span class=n>create</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.create class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should perform the necessary steps to set up the environment.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="581 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="582 "></span><span class=k>def</span> <span class=nf>create</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="583 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="584 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="585 "></span>
|
|
<span class=linenos data-linenos="586 "></span><span class=sd> This should perform the necessary steps to set up the environment.</span>
|
|
<span class=linenos data-linenos="587 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.remove class="doc doc-heading"> <code class="highlight language-python"><span class=n>remove</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.remove class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should perform the necessary steps to completely remove the environment from the system and will only be triggered manually by users with the <a href=../../../cli/reference/#hatch-env-remove><code>env remove</code></a> or <a href=../../../cli/reference/#hatch-env-prune><code>env prune</code></a> commands.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="589 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="590 "></span><span class=k>def</span> <span class=nf>remove</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="591 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="592 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="593 "></span>
|
|
<span class=linenos data-linenos="594 "></span><span class=sd> This should perform the necessary steps to completely remove the environment from the system and will only</span>
|
|
<span class=linenos data-linenos="595 "></span><span class=sd> be triggered manually by users with the [`env remove`](../../cli/reference.md#hatch-env-remove) or</span>
|
|
<span class=linenos data-linenos="596 "></span><span class=sd> [`env prune`](../../cli/reference.md#hatch-env-prune) commands.</span>
|
|
<span class=linenos data-linenos="597 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.exists class="doc doc-heading"> <code class="highlight language-python"><span class=n>exists</span><span class=p>()</span> <span class=o>-></span> <span class=nb>bool</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.exists class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should indicate whether or not the environment has already been created.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="599 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="600 "></span><span class=k>def</span> <span class=nf>exists</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="601 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="602 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="603 "></span>
|
|
<span class=linenos data-linenos="604 "></span><span class=sd> This should indicate whether or not the environment has already been created.</span>
|
|
<span class=linenos data-linenos="605 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.install_project class="doc doc-heading"> <code class="highlight language-python"><span class=n>install_project</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should install the project in the environment.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="607 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="608 "></span><span class=k>def</span> <span class=nf>install_project</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="609 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="610 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="611 "></span>
|
|
<span class=linenos data-linenos="612 "></span><span class=sd> This should install the project in the environment.</span>
|
|
<span class=linenos data-linenos="613 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.install_project_dev_mode class="doc doc-heading"> <code class="highlight language-python"><span class=n>install_project_dev_mode</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.install_project_dev_mode class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should install the project in the environment such that the environment always reflects the current state of the project.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="615 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="616 "></span><span class=k>def</span> <span class=nf>install_project_dev_mode</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="617 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="618 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="619 "></span>
|
|
<span class=linenos data-linenos="620 "></span><span class=sd> This should install the project in the environment such that the environment</span>
|
|
<span class=linenos data-linenos="621 "></span><span class=sd> always reflects the current state of the project.</span>
|
|
<span class=linenos data-linenos="622 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.dependencies_in_sync class="doc doc-heading"> <code class="highlight language-python"><span class=n>dependencies_in_sync</span><span class=p>()</span> <span class=o>-></span> <span class=nb>bool</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.dependencies_in_sync class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should indicate whether or not the environment is compatible with the current <a href=./#hatch.env.plugin.interface.EnvironmentInterface.dependencies>dependencies</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="624 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="625 "></span><span class=k>def</span> <span class=nf>dependencies_in_sync</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=nb>bool</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="626 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="627 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="628 "></span>
|
|
<span class=linenos data-linenos="629 "></span><span class=sd> This should indicate whether or not the environment is compatible with the current</span>
|
|
<span class=linenos data-linenos="630 "></span><span class=sd> [dependencies](reference.md#hatch.env.plugin.interface.EnvironmentInterface.dependencies).</span>
|
|
<span class=linenos data-linenos="631 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.sync_dependencies class="doc doc-heading"> <code class="highlight language-python"><span class=n>sync_dependencies</span><span class=p>()</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-abstractmethod"><code>abstractmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.sync_dependencies class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p><span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 22H2V2h2v20M22 7H6v3h16V7m-6 7H6v3h10v-3Z"/></svg></span> <strong>REQUIRED</strong> <span class=twemoji><svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 2h2v20h-2V2M2 10h16V7H2v3m6 7h10v-3H8v3Z"/></svg></span></p> <p>This should install the <a href=./#hatch.env.plugin.interface.EnvironmentInterface.dependencies>dependencies</a> in the environment.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="633 "></span><span class=nd>@abstractmethod</span>
|
|
<span class=linenos data-linenos="634 "></span><span class=k>def</span> <span class=nf>sync_dependencies</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="635 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="636 "></span><span class=sd> :material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:</span>
|
|
<span class=linenos data-linenos="637 "></span>
|
|
<span class=linenos data-linenos="638 "></span><span class=sd> This should install the</span>
|
|
<span class=linenos data-linenos="639 "></span><span class=sd> [dependencies](reference.md#hatch.env.plugin.interface.EnvironmentInterface.dependencies)</span>
|
|
<span class=linenos data-linenos="640 "></span><span class=sd> in the environment.</span>
|
|
<span class=linenos data-linenos="641 "></span><span class=sd> """</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.build_environment class="doc doc-heading"> <code class="highlight language-python"><span class=n>build_environment</span><span class=p>(</span><span class=n>dependencies</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>])</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.build_environment class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This should set up an isolated environment in which to <a href=../../../cli/reference/#hatch-build><code>build</code></a> the project given a set of dependencies and must be a context manager:</p> <div class=highlight><pre><span></span><code><span class=k>with</span> <span class=n>environment</span><span class=o>.</span><span class=n>build_environment</span><span class=p>([</span><span class=o>...</span><span class=p>]):</span>
|
|
<span class=o>...</span>
|
|
</code></pre></div> <p>The build environment should reflect any <a href=./#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars>environment variables</a> the user defined either currently or at the time of <a href=./#hatch.env.plugin.interface.EnvironmentInterface.create>creation</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="643 "></span><span class=nd>@contextmanager</span>
|
|
<span class=linenos data-linenos="644 "></span><span class=k>def</span> <span class=nf>build_environment</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>dependencies</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="645 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="646 "></span><span class=sd> This should set up an isolated environment in which to [`build`](../../cli/reference.md#hatch-build) the project</span>
|
|
<span class=linenos data-linenos="647 "></span><span class=sd> given a set of dependencies and must be a context manager:</span>
|
|
<span class=linenos data-linenos="648 "></span>
|
|
<span class=linenos data-linenos="649 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="650 "></span><span class=sd> with environment.build_environment([...]):</span>
|
|
<span class=linenos data-linenos="651 "></span><span class=sd> ...</span>
|
|
<span class=linenos data-linenos="652 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="653 "></span>
|
|
<span class=linenos data-linenos="654 "></span><span class=sd> The build environment should reflect any</span>
|
|
<span class=linenos data-linenos="655 "></span><span class=sd> [environment variables](reference.md#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars)</span>
|
|
<span class=linenos data-linenos="656 "></span><span class=sd> the user defined either currently or at the time of</span>
|
|
<span class=linenos data-linenos="657 "></span><span class=sd> [creation](reference.md#hatch.env.plugin.interface.EnvironmentInterface.create).</span>
|
|
<span class=linenos data-linenos="658 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="659 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>get_env_vars</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="660 "></span> <span class=k>yield</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.get_build_process class="doc doc-heading"> <code class="highlight language-python"><span class=n>get_build_process</span><span class=p>(</span><span class=n>build_environment</span><span class=p>,</span> <span class=o>**</span><span class=n>kwargs</span><span class=p>)</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_build_process class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This will be called when the <a href=./#hatch.env.plugin.interface.EnvironmentInterface.build_environment>build environment</a> is active:</p> <div class=highlight><pre><span></span><code><span class=k>with</span> <span class=n>environment</span><span class=o>.</span><span class=n>build_environment</span><span class=p>([</span><span class=o>...</span><span class=p>])</span> <span class=k>as</span> <span class=n>build_environment</span><span class=p>:</span>
|
|
<span class=n>build_process</span> <span class=o>=</span> <span class=n>environment</span><span class=o>.</span><span class=n>get_build_process</span><span class=p>(</span><span class=n>build_environment</span><span class=p>,</span> <span class=o>...</span><span class=p>)</span>
|
|
</code></pre></div> <p>This should return the standard library's <a href=https://docs.python.org/3/library/subprocess.html#subprocess.Popen>subprocess.Popen</a> with all output captured by <code>stdout</code>. The command is constructed by passing all keyword arguments to <a href=./#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command>construct_build_command</a>.</p> <p>For an example, open the default implementation below:</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="662 "></span><span class=k>def</span> <span class=nf>get_build_process</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>build_environment</span><span class=p>,</span> <span class=o>**</span><span class=n>kwargs</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="663 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="664 "></span><span class=sd> This will be called when the</span>
|
|
<span class=linenos data-linenos="665 "></span><span class=sd> [build environment](reference.md#hatch.env.plugin.interface.EnvironmentInterface.build_environment)</span>
|
|
<span class=linenos data-linenos="666 "></span><span class=sd> is active:</span>
|
|
<span class=linenos data-linenos="667 "></span>
|
|
<span class=linenos data-linenos="668 "></span><span class=sd> ```python</span>
|
|
<span class=linenos data-linenos="669 "></span><span class=sd> with environment.build_environment([...]) as build_environment:</span>
|
|
<span class=linenos data-linenos="670 "></span><span class=sd> build_process = environment.get_build_process(build_environment, ...)</span>
|
|
<span class=linenos data-linenos="671 "></span><span class=sd> ```</span>
|
|
<span class=linenos data-linenos="672 "></span>
|
|
<span class=linenos data-linenos="673 "></span><span class=sd> This should return the standard library's</span>
|
|
<span class=linenos data-linenos="674 "></span><span class=sd> [subprocess.Popen](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)</span>
|
|
<span class=linenos data-linenos="675 "></span><span class=sd> with all output captured by `stdout`. The command is constructed by passing all keyword arguments to</span>
|
|
<span class=linenos data-linenos="676 "></span><span class=sd> [construct_build_command](reference.md#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command).</span>
|
|
<span class=linenos data-linenos="677 "></span>
|
|
<span class=linenos data-linenos="678 "></span><span class=sd> For an example, open the default implementation below:</span>
|
|
<span class=linenos data-linenos="679 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="680 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>capture_process</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>construct_build_command</span><span class=p>(</span><span class=o>**</span><span class=n>kwargs</span><span class=p>))</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.construct_build_command class="doc doc-heading"> <code class="highlight language-python"><span class=n>construct_build_command</span><span class=p>(</span><span class=o>*</span><span class=p>,</span> <span class=n>directory</span> <span class=o>=</span> <span class=kc>None</span><span class=p>,</span> <span class=n>targets</span> <span class=o>=</span> <span class=p>(),</span> <span class=n>hooks_only</span> <span class=o>=</span> <span class=kc>False</span><span class=p>,</span> <span class=n>no_hooks</span> <span class=o>=</span> <span class=kc>False</span><span class=p>,</span> <span class=n>clean</span> <span class=o>=</span> <span class=kc>False</span><span class=p>,</span> <span class=n>clean_hooks_after</span> <span class=o>=</span> <span class=kc>False</span><span class=p>,</span> <span class=n>clean_only</span> <span class=o>=</span> <span class=kc>False</span><span class=p>)</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_build_command class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This is the canonical way <a href=../../../cli/reference/#hatch-build><code>build</code></a> command options are translated to a subprocess command issued to <a href=../../builder/reference/ >builders</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="738 "></span><span class=k>def</span> <span class=nf>construct_build_command</span><span class=p>(</span>
|
|
<span class=linenos data-linenos="739 "></span> <span class=bp>self</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="740 "></span> <span class=o>*</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="741 "></span> <span class=n>directory</span><span class=o>=</span><span class=kc>None</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="742 "></span> <span class=n>targets</span><span class=o>=</span><span class=p>(),</span>
|
|
<span class=linenos data-linenos="743 "></span> <span class=n>hooks_only</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="744 "></span> <span class=n>no_hooks</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="745 "></span> <span class=n>clean</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="746 "></span> <span class=n>clean_hooks_after</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="747 "></span> <span class=n>clean_only</span><span class=o>=</span><span class=kc>False</span><span class=p>,</span>
|
|
<span class=linenos data-linenos="748 "></span><span class=p>):</span>
|
|
<span class=linenos data-linenos="749 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="750 "></span><span class=sd> This is the canonical way [`build`](../../cli/reference.md#hatch-build) command options are translated to</span>
|
|
<span class=linenos data-linenos="751 "></span><span class=sd> a subprocess command issued to [builders](../builder/reference.md).</span>
|
|
<span class=linenos data-linenos="752 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="753 "></span> <span class=n>command</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'python'</span><span class=p>,</span> <span class=s1>'-u'</span><span class=p>,</span> <span class=s1>'-m'</span><span class=p>,</span> <span class=s1>'hatchling'</span><span class=p>,</span> <span class=s1>'build'</span><span class=p>,</span> <span class=s1>'--app'</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="754 "></span>
|
|
<span class=linenos data-linenos="755 "></span> <span class=k>if</span> <span class=n>directory</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="756 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>((</span><span class=s1>'--directory'</span><span class=p>,</span> <span class=n>directory</span><span class=p>))</span>
|
|
<span class=linenos data-linenos="757 "></span>
|
|
<span class=linenos data-linenos="758 "></span> <span class=k>if</span> <span class=n>targets</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="759 "></span> <span class=k>for</span> <span class=n>target</span> <span class=ow>in</span> <span class=n>targets</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="760 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>((</span><span class=s1>'--target'</span><span class=p>,</span> <span class=n>target</span><span class=p>))</span>
|
|
<span class=linenos data-linenos="761 "></span>
|
|
<span class=linenos data-linenos="762 "></span> <span class=k>if</span> <span class=n>hooks_only</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="763 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--hooks-only'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="764 "></span>
|
|
<span class=linenos data-linenos="765 "></span> <span class=k>if</span> <span class=n>no_hooks</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="766 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--no-hooks'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="767 "></span>
|
|
<span class=linenos data-linenos="768 "></span> <span class=k>if</span> <span class=n>clean</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="769 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="770 "></span>
|
|
<span class=linenos data-linenos="771 "></span> <span class=k>if</span> <span class=n>clean_hooks_after</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="772 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean-hooks-after'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="773 "></span>
|
|
<span class=linenos data-linenos="774 "></span> <span class=k>if</span> <span class=n>clean_only</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="775 "></span> <span class=n>command</span><span class=o>.</span><span class=n>append</span><span class=p>(</span><span class=s1>'--clean-only'</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="776 "></span>
|
|
<span class=linenos data-linenos="777 "></span> <span class=k>return</span> <span class=n>command</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.command_context class="doc doc-heading"> <code class="highlight language-python"><span class=n>command_context</span><span class=p>()</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.command_context class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>A context manager that when active should make executed shell commands reflect any <a href=./#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars>environment variables</a> the user defined either currently or at the time of <a href=./#hatch.env.plugin.interface.EnvironmentInterface.create>creation</a>.</p> <p>For an example, open the default implementation below:</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="703 "></span><span class=nd>@contextmanager</span>
|
|
<span class=linenos data-linenos="704 "></span><span class=k>def</span> <span class=nf>command_context</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="705 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="706 "></span><span class=sd> A context manager that when active should make executed shell commands reflect any</span>
|
|
<span class=linenos data-linenos="707 "></span><span class=sd> [environment variables](reference.md#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars)</span>
|
|
<span class=linenos data-linenos="708 "></span><span class=sd> the user defined either currently or at the time of</span>
|
|
<span class=linenos data-linenos="709 "></span><span class=sd> [creation](reference.md#hatch.env.plugin.interface.EnvironmentInterface.create).</span>
|
|
<span class=linenos data-linenos="710 "></span>
|
|
<span class=linenos data-linenos="711 "></span><span class=sd> For an example, open the default implementation below:</span>
|
|
<span class=linenos data-linenos="712 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="713 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>get_env_vars</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="714 "></span> <span class=k>yield</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.enter_shell class="doc doc-heading"> <code class="highlight language-python"><span class=n>enter_shell</span><span class=p>(</span><span class=n>name</span><span class=p>,</span> <span class=n>path</span><span class=p>,</span> <span class=n>args</span><span class=p>)</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.enter_shell class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>Spawn a <a href=../../../config/hatch/#shell>shell</a> within the environment.</p> <p>This should either use <a href=./#hatch.env.plugin.interface.EnvironmentInterface.command_context>command_context</a> directly or provide the same guarantee.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="682 "></span><span class=k>def</span> <span class=nf>enter_shell</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>name</span><span class=p>,</span> <span class=n>path</span><span class=p>,</span> <span class=n>args</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="683 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="684 "></span><span class=sd> Spawn a [shell](../../config/hatch.md#shell) within the environment.</span>
|
|
<span class=linenos data-linenos="685 "></span>
|
|
<span class=linenos data-linenos="686 "></span><span class=sd> This should either use</span>
|
|
<span class=linenos data-linenos="687 "></span><span class=sd> [command_context](reference.md#hatch.env.plugin.interface.EnvironmentInterface.command_context)</span>
|
|
<span class=linenos data-linenos="688 "></span><span class=sd> directly or provide the same guarantee.</span>
|
|
<span class=linenos data-linenos="689 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="690 "></span> <span class=k>with</span> <span class=bp>self</span><span class=o>.</span><span class=n>command_context</span><span class=p>():</span>
|
|
<span class=linenos data-linenos="691 "></span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>exit_with_command</span><span class=p>([</span><span class=n>path</span><span class=p>,</span> <span class=o>*</span><span class=n>args</span><span class=p>])</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.run_shell_command class="doc doc-heading"> <code class="highlight language-python"><span class=n>run_shell_command</span><span class=p>(</span><span class=n>command</span><span class=p>:</span> <span class=nb>str</span><span class=p>)</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.run_shell_command class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This should return the standard library's <a href=https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess>subprocess.CompletedProcess</a> and will always be called when the <a href=./#hatch.env.plugin.interface.EnvironmentInterface.command_context>command_context</a> is active, with the expectation of providing the same guarantee.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="693 "></span><span class=k>def</span> <span class=nf>run_shell_command</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>command</span><span class=p>:</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="694 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="695 "></span><span class=sd> This should return the standard library's</span>
|
|
<span class=linenos data-linenos="696 "></span><span class=sd> [subprocess.CompletedProcess](https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess)</span>
|
|
<span class=linenos data-linenos="697 "></span><span class=sd> and will always be called when the</span>
|
|
<span class=linenos data-linenos="698 "></span><span class=sd> [command_context](reference.md#hatch.env.plugin.interface.EnvironmentInterface.command_context)</span>
|
|
<span class=linenos data-linenos="699 "></span><span class=sd> is active, with the expectation of providing the same guarantee.</span>
|
|
<span class=linenos data-linenos="700 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="701 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>run_command</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=n>shell</span><span class=o>=</span><span class=kc>True</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.resolve_commands class="doc doc-heading"> <code class="highlight language-python"><span class=n>resolve_commands</span><span class=p>(</span><span class=n>commands</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>])</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.resolve_commands class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This expands each command into one or more commands based on any <a href=../../../config/environment/overview/#scripts>scripts</a> that the user defined.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="716 "></span><span class=k>def</span> <span class=nf>resolve_commands</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>commands</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="717 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="718 "></span><span class=sd> This expands each command into one or more commands based on any</span>
|
|
<span class=linenos data-linenos="719 "></span><span class=sd> [scripts](../../config/environment/overview.md#scripts) that the user defined.</span>
|
|
<span class=linenos data-linenos="720 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="721 "></span> <span class=k>for</span> <span class=n>command</span> <span class=ow>in</span> <span class=n>commands</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="722 "></span> <span class=k>yield from</span> <span class=bp>self</span><span class=o>.</span><span class=n>expand_command</span><span class=p>(</span><span class=n>command</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.get_env_vars class="doc doc-heading"> <code class="highlight language-python"><span class=n>get_env_vars</span><span class=p>()</span> <span class=o>-></span> <span class=n>EnvVars</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_vars class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>Returns a mapping of environment variables that should be available to the environment. The object can be used as a context manager to temporarily apply the environment variables to the current process.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>The environment variable <code>HATCH_ENV_ACTIVE</code> will always be set to the name of the environment.</p> </div> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="819 "></span><span class=k>def</span> <span class=nf>get_env_vars</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span> <span class=o>-></span> <span class=n>EnvVars</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="820 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="821 "></span><span class=sd> Returns a mapping of environment variables that should be available to the environment. The object can</span>
|
|
<span class=linenos data-linenos="822 "></span><span class=sd> be used as a context manager to temporarily apply the environment variables to the current process.</span>
|
|
<span class=linenos data-linenos="823 "></span>
|
|
<span class=linenos data-linenos="824 "></span><span class=sd> !!! note</span>
|
|
<span class=linenos data-linenos="825 "></span><span class=sd> The environment variable `HATCH_ENV_ACTIVE` will always be set to the name of the environment.</span>
|
|
<span class=linenos data-linenos="826 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="827 "></span> <span class=k>return</span> <span class=n>EnvVars</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>env_vars</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>env_include</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>env_exclude</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.apply_features class="doc doc-heading"> <code class="highlight language-python"><span class=n>apply_features</span><span class=p>(</span><span class=n>requirement</span><span class=p>:</span> <span class=nb>str</span><span class=p>)</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.apply_features class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>A convenience method that applies any user defined <a href=../../../config/environment/overview/#features>features</a> to the given requirement.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="799 "></span><span class=k>def</span> <span class=nf>apply_features</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>requirement</span><span class=p>:</span> <span class=nb>str</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="800 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="801 "></span><span class=sd> A convenience method that applies any user defined [features](../../config/environment/overview.md#features)</span>
|
|
<span class=linenos data-linenos="802 "></span><span class=sd> to the given requirement.</span>
|
|
<span class=linenos data-linenos="803 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="804 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>features</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="805 "></span> <span class=n>features</span> <span class=o>=</span> <span class=s1>','</span><span class=o>.</span><span class=n>join</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>features</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="806 "></span> <span class=k>return</span> <span class=sa>f</span><span class=s1>'</span><span class=si>{</span><span class=n>requirement</span><span class=si>}</span><span class=s1>[</span><span class=si>{</span><span class=n>features</span><span class=si>}</span><span class=s1>]'</span>
|
|
<span class=linenos data-linenos="807 "></span>
|
|
<span class=linenos data-linenos="808 "></span> <span class=k>return</span> <span class=n>requirement</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.construct_pip_install_command class="doc doc-heading"> <code class="highlight language-python"><span class=n>construct_pip_install_command</span><span class=p>(</span><span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>])</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.construct_pip_install_command class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>A convenience method for constructing a <a href=https://pip.pypa.io/en/stable/cli/pip_install/ ><code>pip install</code></a> command with the given verbosity. The default verbosity is set to one less than Hatch's verbosity.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="779 "></span><span class=k>def</span> <span class=nf>construct_pip_install_command</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="780 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="781 "></span><span class=sd> A convenience method for constructing a [`pip install`](https://pip.pypa.io/en/stable/cli/pip_install/)</span>
|
|
<span class=linenos data-linenos="782 "></span><span class=sd> command with the given verbosity. The default verbosity is set to one less than Hatch's verbosity.</span>
|
|
<span class=linenos data-linenos="783 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="784 "></span> <span class=n>command</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'python'</span><span class=p>,</span> <span class=s1>'-u'</span><span class=p>,</span> <span class=s1>'-m'</span><span class=p>,</span> <span class=s1>'pip'</span><span class=p>,</span> <span class=s1>'install'</span><span class=p>,</span> <span class=s1>'--disable-pip-version-check'</span><span class=p>,</span> <span class=s1>'--no-python-version-warning'</span><span class=p>]</span>
|
|
<span class=linenos data-linenos="785 "></span>
|
|
<span class=linenos data-linenos="786 "></span> <span class=c1># Default to -1 verbosity</span>
|
|
<span class=linenos data-linenos="787 "></span> <span class=n>add_verbosity_flag</span><span class=p>(</span><span class=n>command</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>verbosity</span><span class=p>,</span> <span class=n>adjustment</span><span class=o>=-</span><span class=mi>1</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="788 "></span>
|
|
<span class=linenos data-linenos="789 "></span> <span class=n>command</span><span class=o>.</span><span class=n>extend</span><span class=p>(</span><span class=n>args</span><span class=p>)</span>
|
|
<span class=linenos data-linenos="790 "></span> <span class=k>return</span> <span class=n>command</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.join_command_args class="doc doc-heading"> <code class="highlight language-python"><span class=n>join_command_args</span><span class=p>(</span><span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>])</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.join_command_args class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This is used by the <a href=../../../cli/reference/#hatch-run><code>run</code></a> command to construct the root command string from the received arguments.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="792 "></span><span class=k>def</span> <span class=nf>join_command_args</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>args</span><span class=p>:</span> <span class=nb>list</span><span class=p>[</span><span class=nb>str</span><span class=p>]):</span>
|
|
<span class=linenos data-linenos="793 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="794 "></span><span class=sd> This is used by the [`run`](../../cli/reference.md#hatch-run) command to construct the root command string</span>
|
|
<span class=linenos data-linenos="795 "></span><span class=sd> from the received arguments.</span>
|
|
<span class=linenos data-linenos="796 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="797 "></span> <span class=k>return</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>join_command_args</span><span class=p>(</span><span class=n>args</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.check_compatibility class="doc doc-heading"> <code class="highlight language-python"><span class=n>check_compatibility</span><span class=p>()</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.check_compatibility class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>This raises an exception if the environment is not compatible with the user's setup. The default behavior checks for <a href=../../../config/environment/overview/#supported-platforms>platform compatibility</a> and any method override should keep this check.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="810 "></span><span class=k>def</span> <span class=nf>check_compatibility</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="811 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="812 "></span><span class=sd> This raises an exception if the environment is not compatible with the user's setup. The default behavior</span>
|
|
<span class=linenos data-linenos="813 "></span><span class=sd> checks for [platform compatibility](../../config/environment/overview.md#supported-platforms)</span>
|
|
<span class=linenos data-linenos="814 "></span><span class=sd> and any method override should keep this check.</span>
|
|
<span class=linenos data-linenos="815 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="816 "></span> <span class=k>if</span> <span class=bp>self</span><span class=o>.</span><span class=n>platforms</span> <span class=ow>and</span> <span class=bp>self</span><span class=o>.</span><span class=n>platform</span><span class=o>.</span><span class=n>name</span> <span class=ow>not</span> <span class=ow>in</span> <span class=bp>self</span><span class=o>.</span><span class=n>platforms</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="817 "></span> <span class=k>raise</span> <span class=ne>OSError</span><span class=p>(</span><span class=s1>'unsupported platform'</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.get_option_types class="doc doc-heading"> <code class="highlight language-python"><span class=n>get_option_types</span><span class=p>()</span> <span class=o>-></span> <span class=nb>dict</span></code> <span class="doc doc-labels"> <small class="doc doc-label doc-label-staticmethod"><code>staticmethod</code></small> </span> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_option_types class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>Returns a mapping of supported options to their respective types so that they can be used by <a href=../../../config/environment/advanced/#option-overrides>overrides</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="844 "></span><span class=nd>@staticmethod</span>
|
|
<span class=linenos data-linenos="845 "></span><span class=k>def</span> <span class=nf>get_option_types</span><span class=p>()</span> <span class=o>-></span> <span class=nb>dict</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="846 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="847 "></span><span class=sd> Returns a mapping of supported options to their respective types so that they can be used by</span>
|
|
<span class=linenos data-linenos="848 "></span><span class=sd> [overrides](../../config/environment/advanced.md#option-overrides).</span>
|
|
<span class=linenos data-linenos="849 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="850 "></span> <span class=k>return</span> <span class=p>{}</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.get_env_var_option class="doc doc-heading"> <code class="highlight language-python"><span class=n>get_env_var_option</span><span class=p>(</span><span class=n>option</span><span class=p>:</span> <span class=nb>str</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_env_var_option class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>Returns the value of the upper-cased environment variable <code>HATCH_ENV_TYPE_<PLUGIN_NAME>_<option></code>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="829 "></span><span class=k>def</span> <span class=nf>get_env_var_option</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>option</span><span class=p>:</span> <span class=nb>str</span><span class=p>)</span> <span class=o>-></span> <span class=nb>str</span><span class=p>:</span>
|
|
<span class=linenos data-linenos="830 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="831 "></span><span class=sd> Returns the value of the upper-cased environment variable `HATCH_ENV_TYPE_<PLUGIN_NAME>_<option>`.</span>
|
|
<span class=linenos data-linenos="832 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="833 "></span> <span class=k>return</span> <span class=n>os</span><span class=o>.</span><span class=n>environ</span><span class=o>.</span><span class=n>get</span><span class=p>(</span><span class=sa>f</span><span class=s1>'</span><span class=si>{</span><span class=n>AppEnvVars</span><span class=o>.</span><span class=n>ENV_OPTION_PREFIX</span><span class=si>}{</span><span class=bp>self</span><span class=o>.</span><span class=n>PLUGIN_NAME</span><span class=si>}</span><span class=s1>_</span><span class=si>{</span><span class=n>option</span><span class=si>}</span><span class=s1>'</span><span class=o>.</span><span class=n>upper</span><span class=p>(),</span> <span class=s1>''</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> <div class="doc doc-object doc-function"> <h3 id=hatch.env.plugin.interface.EnvironmentInterface.get_context class="doc doc-heading"> <code class="highlight language-python"><span class=n>get_context</span><span class=p>()</span></code> <a href=#hatch.env.plugin.interface.EnvironmentInterface.get_context class=headerlink title="Permanent link">¶</a></h3> <div class="doc doc-contents "> <p>Returns a subclass of <a href=../../utilities/#hatch.env.context.EnvironmentContextFormatter>EnvironmentContextFormatter</a>.</p> <details class=quote> <summary>Source code in <code>hatch/env/plugin/interface.py</code></summary> <div class=highlight><pre><span></span><code><span class=linenos data-linenos="835 "></span><span class=k>def</span> <span class=nf>get_context</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
|
|
<span class=linenos data-linenos="836 "></span> <span class=sd>"""</span>
|
|
<span class=linenos data-linenos="837 "></span><span class=sd> Returns a subclass of</span>
|
|
<span class=linenos data-linenos="838 "></span><span class=sd> [EnvironmentContextFormatter](../utilities.md#hatch.env.context.EnvironmentContextFormatter).</span>
|
|
<span class=linenos data-linenos="839 "></span><span class=sd> """</span>
|
|
<span class=linenos data-linenos="840 "></span> <span class=kn>from</span> <span class=nn>hatch.env.context</span> <span class=kn>import</span> <span class=n>EnvironmentContextFormatter</span>
|
|
<span class=linenos data-linenos="841 "></span>
|
|
<span class=linenos data-linenos="842 "></span> <span class=k>return</span> <span class=n>EnvironmentContextFormatter</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>
|
|
</code></pre></div> </details> </div> </div> </div> </div> </div> <hr> <div class=md-source-file> <small> Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">August 12, 2022</span> </small> </div> </article> </div> </div> </main> <footer class=md-footer> <nav class="md-footer__inner md-grid" aria-label=Footer> <a href=../../metadata-hook/custom/ class="md-footer__link md-footer__link--prev" aria-label="Previous: Custom" rel=prev> <div class="md-footer__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </div> <div class=md-footer__title> <div class=md-ellipsis> <span class=md-footer__direction> Previous </span> Custom </div> </div> </a> <a href=../virtual/ class="md-footer__link md-footer__link--next" aria-label="Next: Virtual" rel=next> <div class=md-footer__title> <div class=md-ellipsis> <span class=md-footer__direction> Next </span> Virtual </div> </div> <div class="md-footer__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg> </div> </a> </nav> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright © Ofek Lev 2017-present </div> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> <div class=md-social> <a href=https://github.com/ofek target=_blank rel=noopener title=github.com class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 480 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M186.1 328.7c0 20.9-10.9 55.1-36.7 55.1s-36.7-34.2-36.7-55.1 10.9-55.1 36.7-55.1 36.7 34.2 36.7 55.1zM480 278.2c0 31.9-3.2 65.7-17.5 95-37.9 76.6-142.1 74.8-216.7 74.8-75.8 0-186.2 2.7-225.6-74.8-14.6-29-20.2-63.1-20.2-95 0-41.9 13.9-81.5 41.5-113.6-5.2-15.8-7.7-32.4-7.7-48.8 0-21.5 4.9-32.3 14.6-51.8 45.3 0 74.3 9 108.8 36 29-6.9 58.8-10 88.7-10 27 0 54.2 2.9 80.4 9.2 34-26.7 63-35.2 107.8-35.2 9.8 19.5 14.6 30.3 14.6 51.8 0 16.4-2.6 32.7-7.7 48.2 27.5 32.4 39 72.3 39 114.2zm-64.3 50.5c0-43.9-26.7-82.6-73.5-82.6-18.9 0-37 3.4-56 6-14.9 2.3-29.8 3.2-45.1 3.2-15.2 0-30.1-.9-45.1-3.2-18.7-2.6-37-6-56-6-46.8 0-73.5 38.7-73.5 82.6 0 87.8 80.4 101.3 150.4 101.3h48.2c70.3 0 150.6-13.4 150.6-101.3zm-82.6-55.1c-25.8 0-36.7 34.2-36.7 55.1s10.9 55.1 36.7 55.1 36.7-34.2 36.7-55.1-10.9-55.1-36.7-55.1z"/></svg> </a> <a href=https://ofek.dev/words/ target=_blank rel=noopener title=ofek.dev class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M217.6 96.1c-12.95-.625-24.66 9.156-25.52 22.37-.88 13.23 9.12 24.63 22.32 24.63 79.53 5.188 148.4 74.09 153.6 153.6.828 12.69 11.39 22.43 23.94 22.43.516 0 1.047-.031 1.578-.063 13.22-.843 23.25-12.28 22.39-25.5C409.3 191.8 320.3 102.8 217.6 96.1zM224 0c-17.7 0-32 14.31-32 32s14.33 32 32 32c123.5 0 224 100.5 224 224 0 17.69 14.33 32 32 32s32-14.31 32-32C512 129.2 382.8 0 224 0zm-51.7 226.8c-14.6-2.9-28.3 9-28.3 23.8v50.37c0 10.25 7.127 18.37 16.75 21.1 18.13 6.75 31.26 24.38 31.26 44.1 0 26.5-21.5 47.1-48.01 47.1-26.5 0-48.01-21.5-48.01-47.1V120c0-13.25-10.75-23.1-24.01-23.1l-48.01.008C10.75 96.02 0 106.8 0 120v247.1c0 89.5 82.14 160.2 175 140.7 54.38-11.5 98.27-55.5 109.8-109.7 17.4-82-37-156.3-112.5-171.3z"/></svg> </a> <a href=https://twitter.com/Ofekmeister target=_blank rel=noopener title=twitter.com class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg> </a> <a href=https://www.linkedin.com/in/ofeklev/ target=_blank rel=noopener title=www.linkedin.com class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"/></svg> </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <script id=__config type=application/json>{"base": "../../..", "features": ["navigation.sections", "navigation.expand", "navigation.tabs", "navigation.tabs.sticky", "navigation.instant"], "search": "../../../assets/javascripts/workers/search.b97dbffb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}, "version": {"provider": "mike"}}</script> <script src=../../../assets/javascripts/bundle.6c7ad80a.min.js></script> </body> </html> |