|
| 1 | +# hatch |
| 2 | + |
| 3 | +Hatch is a modern, extensible Python project manager. |
| 4 | + |
| 5 | + |
| 6 | +## How to install it? |
| 7 | + |
| 8 | +Install using `pip` |
| 9 | +```bash |
| 10 | +$ pip install hatch |
| 11 | +``` |
| 12 | + |
| 13 | +Or, install using `pipx` |
| 14 | +```bash |
| 15 | +$ pipx install hatch |
| 16 | +``` |
| 17 | + |
| 18 | +Or, install using `conda` |
| 19 | +```bash |
| 20 | +$ conda install -c conda-forge hatch |
| 21 | +``` |
| 22 | + |
| 23 | +For MacOS users, Hatch could be installed by using Homebrew, |
| 24 | +```bash |
| 25 | +$ brew install hatch |
| 26 | +``` |
| 27 | + |
| 28 | +For more information about Hatch installtion, please see the [official documentation](https://hatch.pypa.io/latest/install/) |
| 29 | + |
| 30 | + |
| 31 | +## How to use it? |
| 32 | + |
| 33 | +#### 1. Create a virtual environment |
| 34 | + |
| 35 | +You can create virtual environments by using the following command, |
| 36 | +```bash |
| 37 | +$ hatch env create |
| 38 | +``` |
| 39 | + |
| 40 | +Actually, you never need to manually create the environment, as spawning a shell or running commands within a project will automatically |
| 41 | +trigger the environment creation. |
| 42 | + |
| 43 | +Where the virtual environments would be created? Well, it depends on the operation systems you are using. For my case, I am using Ubuntu, |
| 44 | +the directory that contains the virtual environments are: |
| 45 | +```bash |
| 46 | +~/.local/share/hatch/env/virtual |
| 47 | +``` |
| 48 | + |
| 49 | +#### 2. Activate the virtual environment |
| 50 | + |
| 51 | +Using the `env show` command to list all available virtual environments: |
| 52 | +```bash |
| 53 | +$ hatch env show --ascii |
| 54 | +``` |
| 55 | + |
| 56 | +Spawn a shell to activate and use the environment, |
| 57 | +```bash |
| 58 | +$ hatch shell |
| 59 | +``` |
| 60 | + |
| 61 | +#### 3. Manage Python packages |
| 62 | + |
| 63 | +#### 4. Deactivate the virtual environment |
| 64 | + |
| 65 | +You can type `exit` to leave the environment, |
| 66 | +```bash |
| 67 | +$ exit |
| 68 | +``` |
| 69 | + |
| 70 | +#### 5. Remove the virtual environment |
| 71 | + |
| 72 | +You can remove a single virtual environment by using this command: |
| 73 | +```bash |
| 74 | +$ hatch env remove |
| 75 | +``` |
| 76 | + |
| 77 | +If you try to remove all of a project's environments by using this command: |
| 78 | +```bash |
| 79 | +$ hatch env prune |
| 80 | +``` |
| 81 | + |
| 82 | +## Different Python versions? |
| 83 | + |
0 commit comments