1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to use Hatch to run Python CLI

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to work through a pretty basic "hello world" type of example to setup a Python CLI using the Hatch build system (which I understand uses the Click library under the hood).

    I've got a minimally reproducible example below, and the error I'm running into appears below the following code snippet.

    python -m venv .venv
    source .venv/bin/activate
    pip install hatch
    hatch new "new cli" --cli
    cd new-cli
    hatch build
    hatch run new-cli


    And then I get the following error:

    /bin/sh: new-cli: command not found


    I've got the following defined in the pyproject.toml file that gets auto-generated by Hatch.

    [tool.hatch.envs.default.scripts]
    new-cli = "new_cli.cli:new_cli"


    I feel like I'm overlooking some very basic here, but I can't seem to figure out what it is. I've tried running hatch shell prior to the hatch run new-cli, but nothing seems to work.

    Continue reading...

Compartilhe esta Página