Skip to content

Commit 81a3623

Browse files
docs: simplify env setup in create-python-package to venv by default
Co-authored-by: Jaime Rodríguez-Guerra <2559438+jaimergp@users.noreply.github.com>
1 parent 8c658f9 commit 81a3623

1 file changed

Lines changed: 33 additions & 23 deletions

File tree

‎tutorials/create-python-package.md‎

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -318,43 +318,40 @@ At this point, you should have:
318318

319319
You are now ready to install (and build) your Python package!
320320

321+
First, open your preferred terminal and `cd` into the directory containing
322+
your project if you are not already there.
323+
324+
Next, create a virtual environment in your project directory and activate it.
325+
We recommend installing packages that you are developing into a virtual
326+
environment rather than directly into your system Python installation.
327+
328+
:::{admonition} Why use `pip` here instead of Hatch?
329+
:class: note
330+
321331
While Hatch can create an environment and install your package for you
322332
(you'll learn how in the [Hatch environments lesson](develop-python-package-hatch)),
323333
this lesson uses `pip` to install your package, so you can see what is happening when a
324334
package is installed into a Python environment that you create.
335+
:::
325336

326-
First, open your preferred shell (Windows users may use something like GitBash)
327-
and `cd` into your project directory if you are not already there.
328-
329-
Next, activate the Python environment that you wish to use. We recommend
330-
installing packages that you are developing into a virtual environment
331-
rather than your system Python. If you don't have one yet:
337+
Create the environment:
332338

333-
- **conda:** install [Miniforge](https://conda-forge.org/download/) (or
334-
[Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)),
335-
then run `conda create -n pyosdev python`
336-
- **venv:** ships with Python; run `python -m venv .venv` in your project
337-
directory. See the [venv docs](https://docs.python.org/3/library/venv.html).
339+
```bash
340+
> python -m venv .venv
341+
```
338342

339343
Then activate it:
340344

341345
::::{tab-set}
342346

343-
:::{tab-item} conda
344-
```bash
345-
> conda activate pyosdev
346-
(pyosdev) >
347-
```
348-
:::
349-
350-
:::{tab-item} venv (macOS / Linux)
347+
:::{tab-item} macOS / Linux
351348
```bash
352349
> source .venv/bin/activate
353350
(.venv) >
354351
```
355352
:::
356353

357-
:::{tab-item} venv (Windows)
354+
:::{tab-item} Windows
358355
```powershell
359356
> .venv\Scripts\activate
360357
(.venv) >
@@ -363,13 +360,26 @@ Then activate it:
363360

364361
::::
365362

363+
:::{admonition} Are you using conda?
364+
:class: dropdown
365+
366+
If you already use conda, you can create and activate a conda environment
367+
instead of a `venv`:
368+
369+
```bash
370+
> conda create -n pyosdev python
371+
> conda activate pyosdev
372+
(pyosdev) >
373+
```
374+
375+
The rest of this lesson works the same way in either environment.
376+
:::
377+
366378
Your prompt will show the environment name once it is active. Now install
367379
your package:
368380

369381
```bash
370-
# Cd into your project directory (if you are not already there)
371-
> cd pyospackage
372-
# Install your package
382+
# Install your package in editable mode (-e)
373383
> python -m pip install -e .
374384

375385
Obtaining file:///Users/leahawasser/Documents/GitHub/pyos/pyosPackage

0 commit comments

Comments
 (0)