-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Huak | ||
|
||
A Python package manager written in Rust inspired by Cargo. | ||
|
||
!!! Warning | ||
`huak` is in an experimental state. | ||
|
||
## Contents | ||
|
||
* [User Guide](./user_guide.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
# User Guide | ||
|
||
!!! Warning | ||
`huak` is in an experimental state. | ||
|
||
## Contents | ||
|
||
1. [Getting started](#getting-started) | ||
1. [Manage your dependencies](#manage-your-dependencies) | ||
1. [Support more of your workflow](#support-more-of-your-workflow) | ||
1. [Distribute your project](#distribute-your-project) | ||
1. [Configure Huak](#configure-huak) | ||
|
||
## Getting started | ||
|
||
### Installation | ||
|
||
> β οΈ WARNING: The PyPI distribution is outdated. Until it is updated you'll need to install `huak` from source. | ||
``` | ||
cargo install --git https://github.com/cnpryer/huak.git huak | ||
``` | ||
|
||
Then add "$HOME/.huak/bin" to your path. | ||
|
||
### Create a new project | ||
|
||
To create a new project use the `new` command. | ||
|
||
```zsh | ||
~/github | ||
β― huak new my-project | ||
``` | ||
|
||
### Or initialize an existing project | ||
|
||
```zsh | ||
~/github/existing-project | ||
β― huak init | ||
``` | ||
|
||
`huak` distinguishes between library and application-like projects. Projects default to the library type if a type isn't specified. Specify the type with either the `--lib` or `--app` flag. | ||
|
||
Initializing an existing project adds a `pyproject.toml` to the current directory. Bootstrapping the project with the `new` command creates a Python project with the following structure: | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― tree . | ||
. | ||
βββ pyproject.toml | ||
βββ src | ||
βΒ Β βββ my_project | ||
βΒ Β βββ __init__.py | ||
βββ tests | ||
βββ test_version.py | ||
``` | ||
|
||
!!! note | ||
Without `--no-vcs` `huak` generates a `git`-initialized project. | ||
|
||
## Manage your dependencies | ||
|
||
### Add a dependency | ||
|
||
Use `huak` to add dependencies to your Python project. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak add xlcsv | ||
``` | ||
|
||
#### Installer Options | ||
|
||
Currently `huak` uses `pip` under the hood for package installation. You can pass additional arguments onto `pip`. Any arguments after `--` are handed off to `pip install`. | ||
|
||
Note that `huak` will use `uv` instead of `pip` in the future (see [this issue](https://github.com/cnpryer/huak/issues/890) for any updates). | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak add torch torchvision torchaudio -- --extra-index-url https://download.pytorch.org/whl/cu117 | ||
``` | ||
|
||
`huak` will add the packages to your pyproject.toml, so passing [PEP 508](https://peps.python.org/pep-0508/) strings would help persist this behavior for future installs. | ||
|
||
!!! Tip | ||
You can also assign dependencies to a group using `--group`. | ||
|
||
### Manually trigger dependency installation | ||
|
||
Use the `init` command again to install the project's dependencies. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak init | ||
``` | ||
|
||
#### Use optional dependency groups | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak add --group my-group | ||
``` | ||
|
||
### Update dependencies | ||
|
||
To update a dependency use the `update` command. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak update xlcsv | ||
``` | ||
|
||
Or attempt to update everything. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak update | ||
``` | ||
|
||
### Remove dependencies | ||
|
||
To remove a dependency from the project use the `remove` command. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak remove xlcsv | ||
``` | ||
|
||
## Support more of your workflow | ||
|
||
Huak ships commands allowing you to format your python code, lint it, and test it. | ||
|
||
### Format your code | ||
|
||
Use the `fmt` command to format your Python project's code. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak fmt | ||
``` | ||
|
||
#### Using --check | ||
|
||
!!! Warning | ||
As of `v0.0.20` `huak` no longer uses `black`. | ||
|
||
Use `--check` if all you want to do is verify your code is already formatted. Note that `huak` currently uses `ruff` to format your code. This means that `--` can only pass options to `ruff`. Use the `[tool.ruff]` for more configuration. | ||
|
||
!!! Warning | ||
`huak` will exit prior to running with `--check` if your imports are not sorted. See [#510](https://github.com/cnpryer/huak/issues/510) for the status of this issue. | ||
|
||
### Lint your code | ||
|
||
Use the `lint` command to lint your Python project's code. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 took 2s | ||
β― huak lint | ||
``` | ||
|
||
The `--fix` flag can be used to address any auto-fixable issues. | ||
|
||
`huak` wraps tools like `ruff` for some of its commands. To configure a wrapped tool such as `ruff` use the pyproject.toml file: | ||
|
||
```toml | ||
[tool.ruff] | ||
# ... | ||
``` | ||
|
||
`huak` also uses `mypy` for type-checking. To disable this behavior use `--no-types`. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 took 2s | ||
β― huak lint --no-types | ||
``` | ||
|
||
!!! Note | ||
Currently, since `ruff` is the default tool used by `huak lint`, passing additional options with `--` is reserved for `ruff`. To configure `mypy` use the `[tool.mypy]` approach. This limitation will be addressed in future versions of `huak` (see [#505](https://github.com/cnpryer/huak/issues/505)). | ||
|
||
### Test your code | ||
|
||
Use the `test` command to test your project. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak test | ||
``` | ||
|
||
### Run commands within your project's environment context | ||
|
||
You can use `huak` to run a command within the Python environment your project uses. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak run which python | ||
/Users/chrispryer/github/my-project/.venv/bin/python | ||
``` | ||
|
||
### Activate the virtual environment | ||
|
||
`huak` also implements an `activate` command to activate a virtual environment. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak activate | ||
|
||
(.venv) bash-3.2$ | ||
``` | ||
|
||
!!! Note | ||
Currently `huak` just runs `bash --init-file` on unix systems and uses `powershell` on Windows. | ||
```powershell | ||
(.venv) PS C:\Users\chris\github\my-project> | ||
``` | ||
See [#486](https://github.com/cnpryer/huak/issues/486) for the status on the `activate` command. | ||
|
||
## Manage your Python installations | ||
|
||
By default `huak` will use the first Python interpreter found from your `PATH` environment variable. You can `list` these by using the `python` command. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak python list | ||
1: /Users/chrispryer/.pyenv/shims/python3.11 | ||
2: /Users/chrispryer/.pyenv/shims/python3.10 | ||
... | ||
``` | ||
|
||
So `huak` would use `/Users/chrispryer/.pyenv/shims/python3.11` out of the box. You can use a different installed Python version with `use`. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak python use 3.10 | ||
``` | ||
|
||
## Distribute your project | ||
|
||
### Publish to PyPI | ||
|
||
If you're building a Python package you'd like to share, use `huak build` and `huak publish` to build and publish the project to [PyPI](https://pypi.org). | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak build | ||
|
||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak publish | ||
``` | ||
|
||
### Cleaning up | ||
|
||
Use `huak clean` to clean out the dist/ directory. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 took 26s | ||
β― huak clean | ||
``` | ||
|
||
## Configure Huak | ||
|
||
### Configure shell completion | ||
|
||
With `huak completion` you can setup shell completion for `huak`. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak completion -h | ||
Generates a shell completion script for supported shells. See the help menu for more information on supported shells | ||
|
||
Usage: huak completion [OPTIONS] | ||
|
||
Options: | ||
-s, --shell <shell> [possible values: bash, elvish, fish, powershell, zsh] | ||
-u, --uninstall Uninstalls the completion script from your shell init file. If this flag is passed the --shell is required | ||
-h, --help Print help | ||
``` | ||
|
||
Add `huak completion --shell <shell>` to your shell's initialization to use this feature. | ||
|
||
```zsh | ||
eval "$(huak completion --shell <shell>)" | ||
``` | ||
|
||
## Providing feedback | ||
|
||
Any bugs or suggestions can be submitted as issues [here](https://github.com/cnpryer/huak/issues/new). All feedback is welcome and greatly appreciated β€οΈ. | ||
|
||
```zsh | ||
my-project on master π¦ v0.0.1 via π v3.11.0 | ||
β― huak --version | ||
huak 0.0.20 | ||
``` |