Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support module:entry_point in addition to script.py on command line #8074

Open
callegar opened this issue Nov 5, 2023 · 3 comments
Open
Labels
feature Feature request

Comments

@callegar
Copy link

callegar commented Nov 5, 2023

Is your feature request related to a problem? Please describe.

I would like to be able to use pyinstaller on a module that has an entry point without the need to create a wrapper script.

Describe the solution you'd like
I would like to be able to say pyinstaller -F mymodule:main -n mytool rather than pyinstaller mytool.py which implies the need to create mytool.py.

Describe alternatives you've considered
N/A

Additional context
N/A

@callegar callegar added feature Feature request triage Please triage and relabel this issue labels Nov 5, 2023
@bwoodsend
Copy link
Member

Doesn't mymodule have a __main__.py submodule which runs the entry-point function? If it does, just run PyInstaller on that. If it doesn't then add it so that people who don't have their scripts/bin directory in PATH are able to run the entry-point (via python -m mymodule).

@callegar callegar changed the title Support package.module:entry_point in addition to script.py on command line Support module:entry_point in addition to script.py on command line Nov 5, 2023
@callegar
Copy link
Author

callegar commented Nov 5, 2023

It doesn't, because the package has multiple entry points. Furthermore, I do not like very much the idea of adding __main__.py, because I would not like to touch the package and because the package might need to get a __main__.py in the future, exposing a "default" entry point different from the one I need now.

The fact is that setuptool, the pyproject standardization, poetry, setuptools, etc., all now tend to support the idea of packages with (multiple) entry points declarable via pyproject.toml (e.g., via a [tool.poetry.scripts] section in poetry, or a more standard [project.scripts] entry otherwise). In all cases the syntax is module:callable (or package.module:callable, if the module is inside a package). Would be great to have this syntax supported in pyinstaller too, for homogeneity, and for being able to use pyinstaller on packages one would prefer not to modify.

@rokm
Copy link
Member

rokm commented Nov 6, 2023

On one hand, this seems like a non-trivial change to save the user from creating a two-line entry-point script for their frozen application.

On the other hand, having this would allow us to get rid of that horrible traversal of parent directories when entry-point .py file is in a package (has __init__.py next to it), and just raise an error instead.

So while this is not getting an outright rejection from me, it is, as far as I am concerned, quite low on the priority list.

@rokm rokm removed the triage Please triage and relabel this issue label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request
Projects
None yet
Development

No branches or pull requests

3 participants