Skip to content

Commit 0c5ce3b

Browse files
committed
deploy: 41866f9
1 parent 79c2929 commit 0c5ce3b

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

.doctrees/environment.pickle

1.3 KB
Binary file not shown.
967 Bytes
Binary file not shown.

_sources/package-structure-code/declare-dependencies.md.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ within the code of your project or during development of your package.
3535

3636

3737
### Understanding optional vs. required dependencies
38-
You can think about dependencies as being either optional or required. If they are required, they will be listed in the `[dependency] =` table of your `pyproject.toml` file. If they are optional, they will be listed in the `[optional.dependencies]` table of your `pyproject.toml`.
38+
You can think about dependencies as being either optional or required. If they are required, they will be listed in the `dependencies` key in the `project` table of your `pyproject.toml` file. If they are optional, they will be listed in the `[optional.dependencies]` table of your `pyproject.toml`.
3939

4040
You will learn about both below.
4141

@@ -51,7 +51,7 @@ Within those 2 groups, there are three use cases that you can think about. 1. Co
5151
### Required (or core) dependencies
5252

5353
Required dependencies are called directly within your package's code. On this page we refer to these dependencies
54-
as **core dependencies** as they are needed in order to run your package. You should place your core or required dependencies in the `[dependency]=` table of your `pyproject.toml` file.
54+
as **core dependencies** as they are needed in order to run your package. You should place your core or required dependencies in the `dependencies` key of the `[project]` table of your `pyproject.toml` file.
5555

5656
### Optional dependencies
5757

@@ -120,7 +120,7 @@ dependencies = [
120120

121121
Ideally, you should only list the packages that are
122122
necessary to install and use your package in the
123-
`[dependencies]` section. This minimizes the number of
123+
`dependencies` key in the `[project]` table. This minimizes the number of
124124
additional packages that your users must install as well
125125
as the number of packages that depend upon your package
126126
must also install.
@@ -153,18 +153,18 @@ Optional dependencies for building your documentation, running your tests and bu
153153
* linting and other code cleanup tools
154154

155155
These dependencies are considered optional, because they are not required to install and use your package. Feature
156-
dependencies are considered optional and should also be placed in the `[optional.dependencies]` table.
156+
dependencies are considered optional and should also be placed in the `[project.optional-dependencies]` table.
157157

158158
Optional dependencies can be stored in an
159-
`[optional.dependencies]` table in your **pyproject.toml** file.
159+
`[project.optional-dependencies]` table in your **pyproject.toml** file.
160160

161-
It's important to note that within the `[optional.dependencies]` table, you can store additional, optional dependencies within named sub-groups. This is a different table than the dependencies array located within the `[project]` table discussed above which contains a single array with a single list of required packages.
161+
It's important to note that within the `[project.optional-dependencies]` table, you can store additional, optional dependencies within named sub-groups. This is a different table than the dependencies array located within the `[project]` table discussed above which contains a single array with a single list of required packages.
162162

163163
## Create optional dependency groups
164164

165165
To declare optional dependencies in your **pyproject.toml** file:
166166

167-
1. Add a `[optional.dependencies]` table to your **pyproject.toml** file.
167+
1. Add a `[project.optional-dependencies]` table to your **pyproject.toml** file.
168168
2. Create named groups of dependencies using the syntax:
169169

170170
`group-name = ["dep1", "dep2"]`
@@ -223,9 +223,9 @@ feature = [
223223

224224
:::{figure-md} python-package-dependencies
225225

226-
<img src="../images/python-package-dependencies.png" alt="Diagram showing a ven diagram with three sections representing the dependency groups listed above - docs feature and tests. In the center it says your-package and lists the core dependencies of that package seaborn and numpy. To the right are two arrows. The first shows the command python - m pip install your-package. It them shows how installing your package that way installs only the package and the two core dependencies into a users environment. Below is a second arrow with python -m pip install youPackage[tests]. This leads to an environment with both the package dependencies - your-package, seaborn and numpy and also the tests dependencies including pytest and pytest-cov ">
226+
<img src="../images/python-package-dependencies.png" alt="Diagram showing a Venn diagram with three sections representing the dependency groups listed above - docs feature and tests. In the center it says your-package and lists the core dependencies of that package seaborn and numpy. To the right are two arrows. The first shows the command python - m pip install your-package. It them shows how installing your package that way installs only the package and the two core dependencies into a users environment. Below is a second arrow with python -m pip install youPackage[tests]. This leads to an environment with both the package dependencies - your-package, seaborn and numpy and also the tests dependencies including pytest and pytest-cov ">
227227

228-
When a user installs your package locally using python -m pip install your-package only your package and it's core dependencies get installed. When they install your package `[tests]` pip will install both your package and its core dependencies plus any of the dependencies listed within the tests array of your `[optional.dependencies]` table.
228+
When a user installs your package locally using `python -m pip install your-package` only your package and it's core dependencies get installed. When they install your package `python -m pip install your-package[tests]` pip will install both your package and its core dependencies plus any of the dependencies listed within the tests array of your `[project.optional-dependencies]` table.
229229
:::
230230

231231
:::{admonition} Using `python -m pip install` vs. `pip install`
@@ -250,15 +250,15 @@ groups that you defined above using the syntax:
250250

251251
Above you install:
252252
* dependencies needed for your documentation (`docs`),
253-
* required package dependencies in the `dependency` array and
253+
* required package dependencies in the `dependencies` array and
254254
* your package
255255

256256
using pip. Below you
257257
install your package, required dependencies and optional test dependencies.
258258

259259
`python -m pip install ".[tests]"`
260260

261-
You can install multiple dependency groups in the `[optional.dependencies]` table using:
261+
You can install multiple dependency groups in the `[project.optional-dependencies]` table using:
262262

263263
`python -m pip install ".[docs, tests, lint]"`
264264

objects.inv

4 Bytes
Binary file not shown.

package-structure-code/declare-dependencies.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ <h2>What is a package dependency?<a class="headerlink" href="#what-is-a-package-
528528
within the code of your project or during development of your package.</p>
529529
<section id="understanding-optional-vs-required-dependencies">
530530
<h3>Understanding optional vs. required dependencies<a class="headerlink" href="#understanding-optional-vs-required-dependencies" title="Link to this heading">#</a></h3>
531-
<p>You can think about dependencies as being either optional or required. If they are required, they will be listed in the <code class="docutils literal notranslate"><span class="pre">[dependency]</span> <span class="pre">=</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code> file. If they are optional, they will be listed in the <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code>.</p>
531+
<p>You can think about dependencies as being either optional or required. If they are required, they will be listed in the <code class="docutils literal notranslate"><span class="pre">dependencies</span></code> key in the <code class="docutils literal notranslate"><span class="pre">project</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code> file. If they are optional, they will be listed in the <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code>.</p>
532532
<p>You will learn about both below.</p>
533533
<figure class="align-default" id="python-package-dependency-types">
534534
<img alt="" src="../_images/python-package-dependency-types.png" />
@@ -541,7 +541,7 @@ <h3>Understanding optional vs. required dependencies<a class="headerlink" href="
541541
<section id="required-or-core-dependencies">
542542
<h3>Required (or core) dependencies<a class="headerlink" href="#required-or-core-dependencies" title="Link to this heading">#</a></h3>
543543
<p>Required dependencies are called directly within your package’s code. On this page we refer to these dependencies
544-
as <strong>core dependencies</strong> as they are needed in order to run your package. You should place your core or required dependencies in the <code class="docutils literal notranslate"><span class="pre">[dependency]=</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code> file.</p>
544+
as <strong>core dependencies</strong> as they are needed in order to run your package. You should place your core or required dependencies in the <code class="docutils literal notranslate"><span class="pre">dependencies</span></code> key of the <code class="docutils literal notranslate"><span class="pre">[project]</span></code> table of your <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code> file.</p>
545545
</section>
546546
<section id="optional-dependencies">
547547
<h3>Optional dependencies<a class="headerlink" href="#optional-dependencies" title="Link to this heading">#</a></h3>
@@ -601,7 +601,7 @@ <h3>Add required dependencies to your pyproject.toml file<a class="headerlink" h
601601
</div>
602602
<p>Ideally, you should only list the packages that are
603603
necessary to install and use your package in the
604-
<code class="docutils literal notranslate"><span class="pre">[dependencies]</span></code> section. This minimizes the number of
604+
<code class="docutils literal notranslate"><span class="pre">dependencies</span></code> key in the <code class="docutils literal notranslate"><span class="pre">[project]</span></code> table. This minimizes the number of
605605
additional packages that your users must install as well
606606
as the number of packages that depend upon your package
607607
must also install.</p>
@@ -629,17 +629,17 @@ <h3>Optional dependencies<a class="headerlink" href="#id2" title="Link to this h
629629
<li><p>linting and other code cleanup tools</p></li>
630630
</ul>
631631
<p>These dependencies are considered optional, because they are not required to install and use your package. Feature
632-
dependencies are considered optional and should also be placed in the <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table.</p>
632+
dependencies are considered optional and should also be placed in the <code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table.</p>
633633
<p>Optional dependencies can be stored in an
634-
<code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table in your <strong>pyproject.toml</strong> file.</p>
635-
<p>It’s important to note that within the <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table, you can store additional, optional dependencies within named sub-groups. This is a different table than the dependencies array located within the <code class="docutils literal notranslate"><span class="pre">[project]</span></code> table discussed above which contains a single array with a single list of required packages.</p>
634+
<code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table in your <strong>pyproject.toml</strong> file.</p>
635+
<p>It’s important to note that within the <code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table, you can store additional, optional dependencies within named sub-groups. This is a different table than the dependencies array located within the <code class="docutils literal notranslate"><span class="pre">[project]</span></code> table discussed above which contains a single array with a single list of required packages.</p>
636636
</section>
637637
</section>
638638
<section id="create-optional-dependency-groups">
639639
<h2>Create optional dependency groups<a class="headerlink" href="#create-optional-dependency-groups" title="Link to this heading">#</a></h2>
640640
<p>To declare optional dependencies in your <strong>pyproject.toml</strong> file:</p>
641641
<ol class="arabic simple">
642-
<li><p>Add a <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table to your <strong>pyproject.toml</strong> file.</p></li>
642+
<li><p>Add a <code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table to your <strong>pyproject.toml</strong> file.</p></li>
643643
<li><p>Create named groups of dependencies using the syntax:</p></li>
644644
</ol>
645645
<p><code class="docutils literal notranslate"><span class="pre">group-name</span> <span class="pre">=</span> <span class="pre">[&quot;dep1&quot;,</span> <span class="pre">&quot;dep2&quot;]</span></code></p>
@@ -686,9 +686,9 @@ <h2>Create optional dependency groups<a class="headerlink" href="#create-optiona
686686
<section id="install-dependency-groups">
687687
<h3>Install dependency groups<a class="headerlink" href="#install-dependency-groups" title="Link to this heading">#</a></h3>
688688
<figure class="align-default" id="id3">
689-
<img alt="Diagram showing a ven diagram with three sections representing the dependency groups listed above - docs feature and tests. In the center it says your-package and lists the core dependencies of that package seaborn and numpy. To the right are two arrows. The first shows the command python - m pip install your-package. It them shows how installing your package that way installs only the package and the two core dependencies into a users environment. Below is a second arrow with python -m pip install youPackage[tests]. This leads to an environment with both the package dependencies - your-package, seaborn and numpy and also the tests dependencies including pytest and pytest-cov" src="../_images/python-package-dependencies.png" />
689+
<img alt="Diagram showing a Venn diagram with three sections representing the dependency groups listed above - docs feature and tests. In the center it says your-package and lists the core dependencies of that package seaborn and numpy. To the right are two arrows. The first shows the command python - m pip install your-package. It them shows how installing your package that way installs only the package and the two core dependencies into a users environment. Below is a second arrow with python -m pip install youPackage[tests]. This leads to an environment with both the package dependencies - your-package, seaborn and numpy and also the tests dependencies including pytest and pytest-cov" src="../_images/python-package-dependencies.png" />
690690
<figcaption>
691-
<p><span class="caption-text">When a user installs your package locally using python -m pip install your-package only your package and it’s core dependencies get installed. When they install your package <code class="docutils literal notranslate"><span class="pre">[tests]</span></code> pip will install both your package and its core dependencies plus any of the dependencies listed within the tests array of your <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table.</span><a class="headerlink" href="#id3" title="Link to this image">#</a></p>
691+
<p><span class="caption-text">When a user installs your package locally using <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">your-package</span></code> only your package and it’s core dependencies get installed. When they install your package <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">your-package[tests]</span></code> pip will install both your package and its core dependencies plus any of the dependencies listed within the tests array of your <code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table.</span><a class="headerlink" href="#id3" title="Link to this image">#</a></p>
692692
</figcaption>
693693
</figure>
694694
<div class="admonition-using-python-m-pip-install-vs-pip-install admonition">
@@ -708,13 +708,13 @@ <h3>Install dependency groups<a class="headerlink" href="#install-dependency-gro
708708
<p>Above you install:</p>
709709
<ul class="simple">
710710
<li><p>dependencies needed for your documentation (<code class="docutils literal notranslate"><span class="pre">docs</span></code>),</p></li>
711-
<li><p>required package dependencies in the <code class="docutils literal notranslate"><span class="pre">dependency</span></code> array and</p></li>
711+
<li><p>required package dependencies in the <code class="docutils literal notranslate"><span class="pre">dependencies</span></code> array and</p></li>
712712
<li><p>your package</p></li>
713713
</ul>
714714
<p>using pip. Below you
715715
install your package, required dependencies and optional test dependencies.</p>
716716
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">&quot;.[tests]&quot;</span></code></p>
717-
<p>You can install multiple dependency groups in the <code class="docutils literal notranslate"><span class="pre">[optional.dependencies]</span></code> table using:</p>
717+
<p>You can install multiple dependency groups in the <code class="docutils literal notranslate"><span class="pre">[project.optional-dependencies]</span></code> table using:</p>
718718
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">&quot;.[docs,</span> <span class="pre">tests,</span> <span class="pre">lint]&quot;</span></code></p>
719719
<div class="tip admonition">
720720
<p class="admonition-title">For zsh shell users</p>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)