summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-10 08:42:31 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-10 08:42:31 -0400
commit8a76f3869c6f2926e225cd000125cae9c4246989 (patch)
treee847ca5f2e9954256d185ec2b6b36e8d5ae6790f
parenteb88c1fcc88de66c90b3305878e9ff7e954340ba (diff)
parentc6fd22b57e5f8a0db880344b06ab5c19b9e0827d (diff)
downloadpython-coveragepy-git-8a76f3869c6f2926e225cd000125cae9c4246989.tar.gz
Merge Brett's __main__.py file for the tree.
-rw-r--r--MANIFEST.in1
-rw-r--r--__main__.py16
2 files changed, 17 insertions, 0 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 65a60a06..19663a2d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -9,3 +9,4 @@ include README.txt
include CHANGES.txt
include AUTHORS.txt
prune test
+prune __main__.py
diff --git a/__main__.py b/__main__.py
new file mode 100644
index 00000000..7ad6d737
--- /dev/null
+++ b/__main__.py
@@ -0,0 +1,16 @@
+"""Be able to execute coverage.py by pointing Python at the repository's
+directory."""
+import os
+import runpy
+
+
+PKG = 'coverage'
+
+try:
+ run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
+ executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0]
+ if executed != '__main__': # For Python 2.5 compatibility
+ raise ImportError('Incorrectly executed %s instead of __main__' %
+ executed)
+except ImportError: # For Python 2.6 compatibility
+ runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True)