summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Gates <tim.gates@iress.com>2019-06-12 17:02:49 +1000
committerTim Gates <tim.gates@iress.com>2019-06-14 09:41:49 +1000
commit4bae94834e5325fe0d90631641cd2bdaa98b2b55 (patch)
tree8b6b2536f90dbbd78027b58960f324bb8b40f8f0
parentd8d230b554397a145045d15a75b9a8c23b093fe3 (diff)
downloadpelican-4bae94834e5325fe0d90631641cd2bdaa98b2b55.tar.gz
Support for python -m pelican
Addresses https://github.com/getpelican/pelican/issues/2523 Note: @avaris made a good point that there is no need to replace the existing module runner for pelican quickstart or the other tools as this can be run via: > python -m pelican.tools.pelican_quickstart
-rw-r--r--pelican/__main__.py10
-rw-r--r--pelican/tests/test_pelican.py7
-rwxr-xr-xsetup.py2
3 files changed, 18 insertions, 1 deletions
diff --git a/pelican/__main__.py b/pelican/__main__.py
new file mode 100644
index 00000000..141823fc
--- /dev/null
+++ b/pelican/__main__.py
@@ -0,0 +1,10 @@
+"""
+python -m pelican module entry point to run via python -m
+"""
+from __future__ import absolute_import
+
+from . import main
+
+
+if __name__ == '__main__':
+ main()
diff --git a/pelican/tests/test_pelican.py b/pelican/tests/test_pelican.py
index e93c1223..502a45ac 100644
--- a/pelican/tests/test_pelican.py
+++ b/pelican/tests/test_pelican.py
@@ -263,3 +263,10 @@ class TestPelican(LoggedTestCase):
count=1,
msg="Could not process .*parse_error.rst",
level=logging.ERROR)
+
+ def test_module_load(self):
+ """Test loading via python -m pelican --help displays the help"""
+ output = subprocess.check_output([
+ sys.executable, '-m', 'pelican', '--help'
+ ]).decode('ascii', 'replace')
+ assert 'usage:' in output
diff --git a/setup.py b/setup.py
index d1dc4c4d..e8918941 100755
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ requires = ['feedgenerator >= 1.9', 'jinja2 >= 2.7', 'pygments', 'docutils',
entry_points = {
'console_scripts': [
- 'pelican = pelican:main',
+ 'pelican = pelican.__main__:main',
'pelican-import = pelican.tools.pelican_import:main',
'pelican-quickstart = pelican.tools.pelican_quickstart:main',
'pelican-themes = pelican.tools.pelican_themes:main'