Skip to content

Commit 46230f7

Browse files
committed
Fix: more edits from the review
1 parent 2cb6682 commit 46230f7

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

package-structure-code/declare-dependencies.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ a user requires to install your package, can be stored in a
2121
dependencies array located within the `[project]` table of your
2222
pyproject.toml file. This looks something like this:
2323

24-
````toml
24+
```toml
2525
[project]
2626
name = "examplePy"
2727
authors = [
@@ -36,7 +36,7 @@ dependencies = [
3636

3737
## Development dependencies
3838

39-
Dependencies for building your documentation, running your tests and building your package's distribution files are often referred to as development dependencies. These are the dependnecies that a user needs to run core development elements of your package such as:
39+
Dependencies for building your documentation, running your tests and building your package's distribution files are often referred to as development dependencies. These are the dependencies that a user needs to run core development elements of your package such as:
4040

4141
* running your test suite
4242
* building your documentation
@@ -45,11 +45,11 @@ Dependencies for building your documentation, running your tests and building yo
4545
These dependencies can be stored in an
4646
`[optional.dependencies]` table within the **pyproject.toml** file.
4747

48-
```{admonition} What happened to the requirements.txt file for dependencies?
48+
:::{admonition} What happened to the requirements.txt file for dependencies?
4949
:class: note
5050

5151
The requirements.txt file used to be the default way to store dependencies. However in recent years, the ecosystem has moved to storing all of this information in a single **pyproject.toml** file. You may find that some projects do still maintain a requirements.txt file either for specific local development needs OR to support users who may want to create a pip-based virtual environment.
52-
````
52+
:::
5353

5454
## How to declare development dependencies
5555

@@ -60,10 +60,11 @@ To declare dependencies in your **pyproject.toml** file:
6060

6161
`group-name = ["dep1", "dep2"]`
6262

63-
```{tip}
63+
```{admonition} Installing packages from GitHub / Gitlab
64+
:class: tip
6465
6566
If you have dependencies that need to be installed
66-
directly from github using a `git+https` installation
67+
directly from github using a `git+https` installation
6768
approach then you may still need to use a requirements.txt or a conda environment file for your dependency installs.
6869
6970
```
@@ -88,21 +89,33 @@ lint = [
8889

8990
## How to install dependencies from your pyproject.toml
9091

92+
:::{admonition} Using `python -m pip`
93+
94+
In all of the examples in this guide, you will notice we are calling
95+
`pip` using the syntax:
96+
97+
`python -m pip`
98+
99+
Calling pip using `python -m` ensures that the pip that you are using to install your package comes from your current active Python
100+
environment. We strongly suggest that you use this approach whenever
101+
you call `pip` to avoid installation conflicts.
102+
:::
103+
91104
You can install development dependencies using the
92105
groups that you defined above using the syntax:
93106

94-
`pip install .[docs]`
107+
`python -m pip install .[docs]`
95108

96109
Above you install the dependencies needed for your documentation and also your package using pip. Below you
97110
install just the dependencies needed to run your tests:
98111

99-
`pip install .[tests]`
112+
`python -m pip install .[tests]`
100113

101114
You can install all dependencies in the `[optional.dependencies]` table using:
102115

103-
`pip install .[docs, tests, lint]`
116+
`python -m pip install .[docs, tests, lint]`
104117

105-
Each time you call `pip install .[groups-here]`, you are also installing your package locally and also any dependencies
118+
Each time you call `python -m pip install .[groups-here]`, you are also installing your package locally and also any dependencies
106119
that your package needs / has declared in your pyproject.toml file.
107120

108121
```{admonition} For zsh shell users
@@ -111,7 +124,7 @@ that your package needs / has declared in your pyproject.toml file.
111124
Some versions of shell don't support the square bracket syntax. In those cases you will need to add
112125
quotes to your install call like this:
113126
114-
`pip install 'yourPackage.[tests]'`
127+
`python -m pip install 'yourPackage.[tests]'`
115128
116129
```
117130

@@ -133,12 +146,12 @@ dev = [
133146
The above allows you to install both the tests and docs dependency lists
134147
using the command:
135148

136-
`pip install .[dev]`
149+
`python -m pip install .[dev]`
137150

138151
```{tip}
139152
When you install dependencies using the above syntax:
140153
141-
`pip install .[tests, docs]`
154+
`python -m pip install .[tests, docs]`
142155
143156
pip will also install both your package and its core dependencies.
144157
```

0 commit comments

Comments
 (0)