Skip to main content
automodinit v0.16 5th March 2017:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niall Douglas http://www.nedproductions.biz/
See http://pypi.python.org/pypi/automodinit for latest version
Go to http://github.com/ned14/automodinit to report bugs

This package fixes a small problem which has been bugging me throughout
years of python development: forgetting to keep a module's __init__.py
up to date with new files added. This causes the following, irritating
problems:

1. Test suites don't find docstring tests.
2. Static analysis tools don't see some module content in __all__.
3. Things which scan themselves for plugins mismatch what os.listdir()
returns as against what the module import table has.
4. I waste time over something which should take care of itself.
5. os.listdir() based solutions tend to fail when freezed into
an executable binary because they don't understand running from
inside a ZIP archive.

So here's how to make the problem go away forever:

1. Include the automodinit package into your setup.py dependencies.
2. Replace all __init__.py files like this:

__all__ = ["I will get rewritten"]
# Don't modify the line above, or this line!
import automodinit
automodinit.automodinit(__name__, __file__, globals())
del automodinit
# Anything else you want can go after here, it won't get modified.

3. That's it! From now on importing a module will set __all__ to
a list of .py[co] files in the module and will also import each
of those files as though you had typed:

for x in __all__: import x

Therefore the effect of "from M import *" matches exactly "import M".

Customising:
-=-=-=-=-=-=
automodinit can take the following additional parameters:

filter: This is a callable which will be passed a list of tuples
(loader, modulename, ispkg) which is the output of
pkgutil.iter_modules() for the calling module. Return only
those which you want to be imported.
importFindings: Defaults to True. Set to False to not auto-import
the contents of __all__.

Version history:
-=-=-=-=-=-=-=-=
* v0.16 5th Mar 2017
* Fixed stripping of __init__.py file encoding. Thanks to wtyerogers
for reporting this.
* Removed suggestion this is the smallest package on pypi. Thanks to
asl97 for reporting this.
* Tell PyPi we are under the MIT licence. Thanks to njwhite for
reporting this.

* v0.13 9th Feb 2013
* Fixed a bug where the source distribution would fail to install due
to not including distribute_setup.py. Thanks to kanzure for reporting this.

* v0.12 5th Mar 2012
* Fixed a bug where isinstance would occasionally fail. Turns out the
pkgutil loading mechanism doesn't check to see if the module is already
loaded, so it was loading duplicates whose types wouldn't compare.

* v0.11 5th Mar 2012
* Fixed some typos in Readme.txt
* Typically what worked before packaging did not work after. Fixed!

* v0.10 5th Mar 2012
First release

Metadata

Release files for automodinit 0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for automodinit 0.16
File Size Uploaded Provenance
automodinit-0.16.tar.gz 3.7 kB Without provenance Details

Release files / automodinit-0.16.tar.gz

Download URL automodinit-0.16.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fc0d340865be7378fe591c8db162609dea713cfef2e25d9b15836f4cd690c831
BLAKE2b-256 checksum
How to use checksums
7c28214fff05c552d333433ca43f6cabd6d9f5577f878adff9d11e418f28917b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for automodinit 0.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.16 This release

1 release file No provenance

0.14

0.11

0.10

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page