pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.11k stars 310 forks source link

How sync an env with `pyproject.toml` script entries? #1301

Open floschne opened 8 months ago

floschne commented 8 months ago

Hi @ofek and first of all thanks for this amazing work!

Maybe I missed it in the docs but I'm facing issues when I update script entries in pyproject.toml E.g. let's say I have the following entry and a fresh hatch project (i.e., never ran hatch run ... or hatch env create)

[project.scripts]
fibonacci = "autorag.fibonacci:app"

When I run hatch env create && hatch run fibonacci 10 it correctly executes the script.

Now I want to change ,e.g., the name of the script:

[project.scripts]
print_fibonacci = "autorag.fibonacci:app"

When I run hatch env create && hatch run print_fibonacci 10 it prints /bin/sh: print_fibonacci: command not found. Also, when I look into the venv bin dir, I can see the old fibonacci but not the new print_fibonacci.

The only way I found to update and sync the env is to remove my venv dir and create the env from scratch.

Is this behaviour on purpose or did I miss something here?

ofek commented 8 months ago

Yes this is working correctly because metadata is not dynamic. I suppose I could work around this by checking if values have changed and forcing a reinstall.

OceanTrader1 commented 3 months ago

I will echo @floschne's comments. This behaviour is not intuitive to me. Though, if this is the intended behaviour, I think most of this ambiguity could be cleared up with a guided example in the How-to section of the docs.