Poetry VS Pixi when building Python CLI apps #2392
-
When using Poetry, I can have something like this in my
Where
And it still requires |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
My understanding is that It seems it would be best practice to use one of the build backends to install your local project, here contained in |
Beta Was this translation helpful? Give feedback.
-
FWIW I found this a bit non-obvious, although a combo of stackoverflow and hatchling docs got me there in the end. In case it helps someone looking for the magic commands to include, here's what worked for me. If I have a hello world CLI in # file: src/PACKAGE/cli.py
import typer
cli = typer.Typer()
@cli.command()
def hello(name: str):
typer.echo(f"Hello {name}")
if __name__ == "__main__":
cli() ...then this is what I put in the pyproject.toml: # ...
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]
[project.scripts]
pkg_cli = "PACKAGE.cli:cli"
# ... ...and I can just run the command in the pixi shell (or when it gets installed etc): $ pixi shell
(env) $ pkg_cli "world!"
Hello world! |
Beta Was this translation helpful? Give feedback.
FWIW I found this a bit non-obvious, although a combo of stackoverflow and hatchling docs got me there in the end.
In case it helps someone looking for the magic commands to include, here's what worked for me. If I have a hello world CLI in
src/PACKAGE/cli.py
:...then this is what I put in the pyproject.toml:
...and I can just run the command in the pixi shell (or when it gets installed etc):