Skip to content
Permalink
Browse files

Merge pull request #2541 from getnikola/plugin-deps

Plugin deps (Fix #2533)
  • Loading branch information
Kwpolska committed Oct 20, 2016
2 parents 3b0c817 + bd3b8a2 commit 5ee1a3a7f6ccdc6d74d7f58cf2bfa1becfb59835
Showing with 21 additions and 0 deletions.
  1. +1 −0 CHANGES.txt
  2. +20 −0 nikola/plugins/command/plugin.py
@@ -9,6 +9,7 @@ Bugfixes
Features
--------

* Plugins can depend on other plugins being installed (Issue #2533)
* The destination folder in ``POSTS`` and ``PAGES`` can now be
translated (Issue #2116)
* Pass ``post`` object and ``lang`` to post compilers (Issue #2531)
@@ -265,6 +265,7 @@ def do_install(self, url, name, show_install_notes=True):
'package manager.')
else:
LOGGER.info('Dependency installation succeeded.')

reqnpypath = os.path.join(dest_path, 'requirements-nonpy.txt')
if os.path.exists(reqnpypath):
LOGGER.notice('This plugin has third-party '
@@ -280,6 +281,25 @@ def do_install(self, url, name, show_install_notes=True):

print('You have to install those yourself or through a package '
'manager.')

req_plug_path = os.path.join(dest_path, 'requirements-plugins.txt')
if os.path.exists(req_plug_path):
LOGGER.notice('This plugin requires other Nikola plugins.')
LOGGER.info('Installing plugins using Nikola...')
print('Contents of the requirements-nonpy.txt file:\n')
try:
with io.open(req_plug_path, 'r', encoding='utf-8') as inf:
for plugname in inf.readlines():
self.do_install(url, plugname, show_install_notes)
except subprocess.CalledProcessError:
LOGGER.error('Could not install a plugin.')
print('Contents of the requirements-plugins.txt file:\n')
with io.open(req_plug_path, 'r', encoding='utf-8') as fh:
print(utils.indent(fh.read(), 4 * ' '))
print('You have to install those yourself manually.')
else:
LOGGER.info('Dependency installation succeeded.')

confpypath = os.path.join(dest_path, 'conf.py.sample')
if os.path.exists(confpypath) and show_install_notes:
LOGGER.notice('This plugin has a sample config file. Integrate it with yours in order to make this plugin work!')

0 comments on commit 5ee1a3a

Please sign in to comment.