python-3.xhatch

How does one install a package in hatch?


Hatch seems amazing, uses pip rather than an in-house installer, and I want to use it.

However, I have searched through the internet and found many indications that hatch should come with an install command accessed via hatch install. However, on python3.10 @ hatch = 1.6.3, there is no install command:

Usage: hatch [OPTIONS] COMMAND [ARGS]...

   _   _       _       _
  | | | |     | |     | |
  | |_| | __ _| |_ ___| |__
  |  _  |/ _` | __/ __| '_ \
  | | | | (_| | || (__| | | |
  \_| |_/\__,_|\__\___|_| |_|

Options:
  -e, --env TEXT                  The name of the environment to use [env var:
                                  `HATCH_ENV`]
  -p, --project TEXT              The name of the project to work on [env var:
                                  `HATCH_PROJECT`]
  --color / --no-color            Whether or not to display colored output
                                  (default is auto-detection) [env vars:
                                  `FORCE_COLOR`/`NO_COLOR`]
  --interactive / --no-interactive
                                  Whether or not to allow features like
                                  prompts and progress bars (default is auto-
                                  detection) [env var: `HATCH_INTERACTIVE`]
  -v, --verbose                   Increase verbosity (can be used additively)
                                  [env var: `HATCH_VERBOSE`]
  -q, --quiet                     Decrease verbosity (can be used additively)
                                  [env var: `HATCH_QUIET`]
  --data-dir TEXT                 The path to a custom directory used to
                                  persist data [env var: `HATCH_DATA_DIR`]
  --cache-dir TEXT                The path to a custom directory used to cache
                                  data [env var: `HATCH_CACHE_DIR`]
  --config TEXT                   The path to a custom config file to use [env
                                  var: `HATCH_CONFIG`]
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Commands:
  build    Build a project
  clean    Remove build artifacts
  config   Manage the config file
  dep      Manage environment dependencies
  env      Manage project environments
  new      Create or initialize a project
  project  View project information
  publish  Publish build artifacts
  run      Run commands within project environments
  shell    Enter a shell within a project's environment
  status   Show information about the current environment
  version  View or set a project's version

And the dep command:

Usage: hatch dep [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --help  Show this message and exit.

Commands:
  hash  Output a hash of the currently defined dependencies
  show  Display dependencies in various formats

How does one add a dependency with hatch? I'd like to make sure it is as competitive as poetry, which does provide an install option.

Alternatively: is there a newer version of hatch for newer versions of python3 that does have these installation features?

If that is the case, no problem -- I can work around it.


Solution

  • When you do hatch shell or hatch run, Hatch will automatically spawn a new environment to run in and install your project into that environment for you. You don't need to manage doing anything like pip install or hatch install manually.

    It looks like for now you'll need to hand-curate the dependencies.