Skip to content

Commit 912cbb7

Browse files
committed
Update hatch
1 parent 6976625 commit 912cbb7

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Popular Python virtual environment management tools:
1212
* [5] [poetry](poetry/README.md)
1313
* [6] [pyenv + virtualenv](pyenv+virtualenv/README.md)
1414
* [7] [conda](conda/README.md)
15-
* [8] [hatch](hatch/README.md) Continuing
15+
* [8] [hatch](hatch/README.md)
1616
* pdm
1717
* pew
1818
* tox

hatch/README.md

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,50 @@ Within the Hatch project, you can create virtual environments which are defined
7676
$ hatch env create <envname>
7777
```
7878

79-
Actually, you never need to manually create the environment, as spawning a shell or running commands within a project will automatically
80-
trigger the environment creation.
79+
Actually, you never need to manually create the environment, as spawning a shell (see 2 activate the virtual environment) or running commands within a project will automatically trigger the environment creation.
8180

82-
Where the virtual environments would be created? Well, it depends on the operation systems you are using. For my case, I am using Ubuntu,
83-
the directory that contains the virtual environments are:
81+
Where the virtual environments would be created? It's determined by the following heuristic order:
82+
- The `patch` option
83+
- configured `virtual` environment directory
84+
85+
In my case, the directory that contains the virtual environments are:
8486
```bash
8587
~/.local/share/hatch/env/virtual
8688
```
8789

90+
e.g.
91+
92+
```bash
93+
~/.local/share/hatch/env/virtual/hatch-example/
94+
└── qrnKROyH
95+
└── hatch-example
96+
├── bin
97+
│   ├── activate
98+
│   ├── activate.csh
99+
│   ├── activate.fish
100+
│   ├── activate.nu
101+
│   ├── activate.ps1
102+
│   ├── activate_this.py
103+
│   ├── coverage
104+
│   ├── coverage3
105+
│   ├── coverage-3.12
106+
│   ├── normalizer
107+
│   ├── pip
108+
│   ├── pip3
109+
│   ├── pip-3.12
110+
│   ├── pip3.12
111+
│   ├── py.test
112+
│   ├── pytest
113+
│   ├── python -> /home/jianli/.pyenv/versions/3.12.0/bin/python
114+
│   ├── python3 -> python
115+
│   └── python3.12 -> python
116+
├── lib
117+
│   └── python3.12
118+
└── pyvenv.cfg
119+
120+
5 directories, 20 files
121+
```
122+
88123
#### 2. Activate the virtual environment
89124

90125
Using the `env show` command to list all available virtual environments:
@@ -99,14 +134,12 @@ $ hatch shell
99134

100135
#### 3. Manage Python packages
101136

102-
At the time of writing, Hatch does not support dependency lock files, this feature is on roadmap, but until then you will need to
137+
When you run `hatch shell`, Hatch will automatically spawn the environment and install the Python packages listed in `dependencies`.
138+
139+
In active state of the environment, at the time of writing, Hatch does not support dependency lock files, this feature is on roadmap, but until then you will need to
103140
use `pip`, `pip-tools`, or other package management tools alongside Hatch.
104141

105-
Here, we use `pip` to manage Python packages,
106-
107-
```bash
108-
$ pip install <package-name>
109-
```
142+
And, for now you will need to hand-curate the dependencies in `pyproject.toml`.
110143

111144

112145
#### 4. Deactivate the virtual environment
@@ -130,3 +163,11 @@ $ hatch env prune
130163

131164
## Different Python versions?
132165

166+
Virtual environments necessarily require a parent installtion of Python. The Python choice used to create the environment is determined by the version of Python found on your system, or you can set `HATCH_PYTHON` environment variable.
167+
168+
```bash
169+
export HATCH_PYTHON=/usr/bin/python3.11
170+
```
171+
172+
If no version has been chosen, the resolver will try to find a version that matches
173+
the version of Python that Hatch is currently running on.

0 commit comments

Comments
 (0)