Skip to content

Commit 61e6977

Browse files
jhkennedylwasser
authored andcommitted
Always use python -m with pip
1 parent f19777e commit 61e6977

9 files changed

+20
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To build, follow these steps:
4343
1. Install `nox`
4444

4545
```console
46-
$ pip install nox
46+
$ python -m pip install nox
4747
```
4848
2. Build the documentation:
4949

package-structure-code/code-style-linting-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ To setup pre-commit locally, you need to do 3 things:
315315
1. Install pre-commit (and include it as a development requirement in your repository)
316316

317317
```sh
318-
pip install pre-commit
318+
python -m pip install pre-commit
319319

320320
# or
321321

package-structure-code/declare-dependencies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ If you want to support conda users, you may want to also maintain a conda enviro
336336
```{admonition} A note for conda users
337337
:class: tip
338338
339-
If you use a conda environment for developing your tool, keep in mind that when you install your package using `pip install -e .` (or using pip in general), dependencies will be installed from PyPI rather than conda.
339+
If you use a conda environment for developing your tool, keep in mind that when you install your package using `python -m pip install -e .` (or using pip in general), dependencies will be installed from PyPI rather than conda.
340340
341341
Thus, if you are running a conda environment, installing your package in "editable" mode risks dependency conflicts. This is particularly important if you have a spatial package that requires geospatial system libraries like GDAL or another system-level dependency.
342342
343-
Alternatively, you can install your package using `pip install -e . --no-deps` to only install the package. And install the rest of your dependencies using a conda environment file.
343+
Alternatively, you can install your package using `python -m pip install -e . --no-deps` to only install the package. And install the rest of your dependencies using a conda environment file.
344344
```
345345

346346
## Dependencies in Read the Docs

package-structure-code/pyproject-toml-python-package-metadata.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ what dependencies your package requires.
168168

169169
- **dependencies:** dependencies are optional but we strongly suggest you include them in your pyproject.toml. Dependencies will be installed by pip when your project is installed creating a better user-experience.
170170

171-
- **`[project.optional-dependencies]`:** the optional or development dependencies will be installed if someone runs `pip install projectname[dev]`. This is a nice way to include your development dependencies for users who may wish to contribute to your project.
171+
- **`[project.optional-dependencies]`:** the optional or development dependencies will be installed if someone runs `python -m pip install projectname[dev]`. This is a nice way to include your development dependencies for users who may wish to contribute to your project.
172172

173173
- **keywords:** These are the keywords that will appear on your PyPI landing page. Think of them as words that people might use to search for your package.
174174
- **classifiers:** The classifiers section of your metadata is also important for the landing page of your package in PyPI and for filtering of packages in PyPI. A list of [all options for classifiers can be found her](https://PyPI.org/classifiers/)e. Some of the classifiers that you should consider including
@@ -201,13 +201,13 @@ Then specify dependency groups as follows:
201201

202202
Following the above example, you install dependencies like this:
203203

204-
- `pip install -e .[tests]`
204+
- `python -m pip install -e .[tests]`
205205

206206
The above will install both your package in editable mode and all of the dependencies declared in the tests section of your `[project.optional-dependencies]` table.
207207

208208
To install all dependencies and also your package, you'd use:
209209

210-
`pip install -e .[tests,lint,docs]`
210+
`python -m pip install -e .[tests,lint,docs]`
211211

212212
:::{admonition} Recursive dependencies
213213
:class: tip

package-structure-code/python-package-build-tools.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ Install your package in editable mode|✅| Flit supports installing your package
308308
Build your sdist and wheel distributions|✅| Flit can be used to build your packages sdist and wheel distributions.
309309
```
310310

311-
NOTE: _If you are using the most current version of pip, it supports both a symlink approach `flit install -s` and `pip install -e .`_
311+
NOTE: _If you are using the most current version of pip, it supports both a symlink approach `flit install -s` and `python -m pip install -e .`_
312312

313313
```{admonition} Learn more about flit
314314
* [Why use flit?](https://flit.pypa.io/en/stable/rationale.html)
@@ -351,7 +351,7 @@ Publish to PyPI and test PyPI|✅|Hatch supports publishing to both test PyPI an
351351
Version Control based versioning|✅ | Hatch offers `hatch_vcs` which is a plugin that uses setuptools_scm to support versioning using git tags. The workflow with `hatch_vcs` is the same as that with `setuptools_scm`.
352352
Version bumping| ✅ | Hatch supports you bumping the version of your package using standard semantic version terms patch; minor; major
353353
Follows current packaging standards|✅|Hatch supports current packaging standards for adding metadata to the **pyproject.toml** file.
354-
Install your package in editable mode|✅| Hatch will install your package into any of its environments by default in editable mode. You can install your package in editable mode manually using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
354+
Install your package in editable mode|✅| Hatch will install your package into any of its environments by default in editable mode. You can install your package in editable mode manually using `python -m pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
355355
Build your sdist and wheel distributions|✅| Hatch will build the sdist and wheel distributions
356356
✨Matrix environment creation to support testing across Python versions✨|✅| The matrix environment creation is a feature that is unique to Hatch in the packaging ecosystem. This feature is useful if you wish to test your package locally across Python versions (instead of using a tool such as tox).
357357
✨[Nox / MAKEFILE like functionality](https://hatch.pypa.io/latest/environment/#selection)✨| ✅| This feature is also unique to Hatch. This functionality allows you to create workflows in the **pyproject.toml** configuration to do things like serve docs locally and clean your package build directory. This means you may have one less tool in your build workflow.

tutorials/add-readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Remember that the more people understand what your package does, the more people
8989
Next, add instructions that tell users how to install your package.
9090

9191
For example, can they use pip to install your package?
92-
`pip install packagename`
92+
`python -m pip install packagename`
9393

9494
or conda?
9595

@@ -202,7 +202,7 @@ Short description here using non-technical language that describes what your pac
202202

203203
To install this package run:
204204

205-
`pip install pyosPackage`
205+
`python -m pip install pyosPackage`
206206

207207
## OPTIONAL - if you have additional setup instructions add them here. if not, skip this section.
208208

tutorials/installable-code.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ If you try to pip install a package with no `pyproject.toml` you will get the fo
140140

141141
```bash
142142
GitHub/pyospackage/testme
143-
➜ pip install .
143+
python -m pip install .
144144
ERROR: Directory '.' is not installable.
145145
Neither 'setup.py' nor 'pyproject.toml' found.
146146
```
@@ -527,12 +527,12 @@ Obtaining file:///Users/leahawasser/Documents/GitHub/pyos/pyosPackage
527527
# use pip list instead of conda list here if you are working in an venv environment rather than a conda envt
528528
```
529529
530-
:::{admonition} What does `pip install -e .` do?
530+
:::{admonition} What does `python -m pip install -e .` do?
531531
:class: tip
532532
533-
Let's break down `pip install -e .`
533+
Let's break down `python -m pip install -e .`
534534
535-
`pip install -e .` installs your package into the current active
535+
`python -m pip install -e .` installs your package into the current active
536536
Python environment in **editable mode** (`-e`). Installing your package in
537537
editable mode, allows you to work on your code and then test the updates
538538
interactively in your favorite Python interface. One important caveat of editable mode is that every time you update your code, you may need to restart Python.
@@ -606,7 +606,7 @@ If you wish to share your code without publishing to PyPI you can
606606
always install packages directly from GitHub using the syntax:
607607
608608
```bash
609-
pip install git+https://github.com/user/repo.git@branch_or_tag
609+
python -m pip install git+https://github.com/user/repo.git@branch_or_tag
610610
```
611611
612612
To make your package GitHub installable, you can:
@@ -618,7 +618,7 @@ To make your package GitHub installable, you can:
618618
For instance below you install the pyospackage from the main branch of the
619619
pyOpenSci repository.
620620
621-
`pip install git+https://github.com/user/repo.git@branch_or_tag`
621+
`python -m pip install git+https://github.com/user/repo.git@branch_or_tag`
622622
623623
:::
624624

tutorials/publish-conda-forge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Note - this is a tutorial aimed to help you get your package onto conda-forge. T
110110
First, [install grayskull](https://conda.github.io/grayskull/user_guide.html). You can install it using either pip:
111111

112112
```bash
113-
> pip install grayskull
113+
> python -m pip install grayskull
114114
```
115115

116116
or conda

tutorials/publish-pypi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ by default it uses venv[^venv] which is the default environment management tool
142142
Hatch will:
143143

144144
1. Create a new virtualenv (venv) that is located on your computer.
145-
2. Install your package into the environment in editable mode (similar to `pip install -e`). This means it installs both your project and your project's dependencies as declared in your pyproject.toml file.
145+
2. Install your package into the environment in editable mode (similar to `python -m pip install -e`). This means it installs both your project and your project's dependencies as declared in your pyproject.toml file.
146146

147147
## Step 2: Build your package's sdist and wheel distributions
148148

@@ -308,7 +308,7 @@ As an example, [check out our pyOpenSci pyosPackage landing page on TestPyPI](ht
308308
the page has information about the current package version and also
309309
installation instructions as follows:
310310

311-
`pip install -i https://test.pypi.org/simple/ pyosPackage`
311+
`python -m pip install -i https://test.pypi.org/simple/ pyosPackage`
312312

313313
:::{important} Publishing to TestPyPI vs PyPI
314314
While you can install from TestPyPI it's not recommended that you publish to

0 commit comments

Comments
 (0)