From 4d4b19e294e3748b0e68fec4278d5bde0b0011c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Fri, 21 Oct 2011 07:34:00 +0200 Subject: =?UTF-8?q?Document=20that=20packaging=20doesn=E2=80=99t=20create?= =?UTF-8?q?=20=5F=5Finit=5F=5F.py=20files=20(#3902).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bug reported expected distutils to create an __init__.py file for a project using only C extension modules. IMO, how Python imports packages and submodules is well documented, and it’s never suggested that distutils might create an __init__.py file, so I’m adding this clarification to the packaging docs but won’t backport unless other people tell me they shared the same wrong expectation. Thanks to Mike Hoy for his help with the patch. --- Doc/library/packaging.compiler.rst | 4 ++++ Doc/packaging/setupscript.rst | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Doc/library/packaging.compiler.rst b/Doc/library/packaging.compiler.rst index d771972..89b6e45 100644 --- a/Doc/library/packaging.compiler.rst +++ b/Doc/library/packaging.compiler.rst @@ -675,3 +675,7 @@ extension modules. | | abort the build process, but | | | | simply skip the extension. | | +------------------------+--------------------------------+---------------------------+ + +To distribute extension modules that live in a package (e.g. ``package.ext``), +you need to create you need to create a :file:`{package}/__init__.py` file to +let Python recognize and import your module. diff --git a/Doc/packaging/setupscript.rst b/Doc/packaging/setupscript.rst index dbac3dd..cafde20 100644 --- a/Doc/packaging/setupscript.rst +++ b/Doc/packaging/setupscript.rst @@ -177,6 +177,10 @@ resulting object code are identical in both cases; the only difference is where in the filesystem (and therefore where in Python's namespace hierarchy) the resulting extension lives. +If your distribution contains only one or more extension modules in a package, +you need to create a :file:`{package}/__init__.py` file anyway, otherwise Python +won't be able to import anything. + If you have a number of extensions all in the same package (or all under the same base package), use the :option:`ext_package` keyword argument to :func:`setup`. For example, :: -- cgit v0.12