What is the simplest way to make an alias for python -m myproject
when the user installs the package myproject
via pip
?
Can poetry
manages that?
Remainder: python -m myproject
launches myproject/__main__.py
.
It is possible. With Poetry, it is solved by its scripts
feature in the pyproject.toml
:
[tool.poetry.scripts]
my-command = "myproject.__main__:my_main"
where my_main
is a function in myproject/__main__.py
:
def my_main():
# ...
if __name__ == '__main__':
my_main()
From then on, you can poetry install
again and then the my-command
executable is available. Later, when one "pip-installs" your project, they also have the my-command
executable available.