classification
Title: Missing documentation on how to make package executable as script
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, dorosch, igo95862, steven.daprano
Priority: normal Keywords: patch

Created on 2020-02-27 09:53 by igo95862, last changed 2021-04-12 08:16 by igo95862. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18677 open dorosch, 2020-02-27 11:39
Messages (2)
msg362790 - (view) Author: igo95862 (igo95862) Date: 2020-02-27 09:53
This is package documentation: https://docs.python.org/3/tutorial/modules.html#packages


To make package executable (python -m package) you need to create a file __main__.py  in the package directory.


This is pretty much not documented anyone aside of trying to run a package missing __main__.py


This page already contains information on how to make module executable. (https://docs.python.org/3/tutorial/modules.html#executing-modules-as-scripts)
msg362791 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-02-27 10:26
You're right that it's hard to find any documentation on package `__main__.py` files. There's nothing here that I can see:

https://docs.python.org/3/reference/import.html#packages

Aside from the tutorial, the only other place I can find it referenced is a really brief aside here:

https://docs.python.org/3/library/__main__.html
History
Date User Action Args
2021-04-12 08:16:06igo95862setstatus: open -> closed
stage: patch review -> resolved
2020-02-27 11:39:02doroschsetkeywords: + patch
nosy: + dorosch

pull_requests: + pull_request18037
stage: patch review
2020-02-27 10:26:26steven.dapranosetnosy: + steven.daprano
messages: + msg362791
2020-02-27 09:53:08igo95862create