Skip to content

Commit

Permalink
Merge pull request #2541 from getnikola/plugin-deps
Browse files Browse the repository at this point in the history
Plugin deps (Fix #2533)
  • Loading branch information
Kwpolska committed Oct 20, 2016
2 parents 3b0c817 + bd3b8a2 commit 5ee1a3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions nikola/plugins/command/plugin.py
Expand Up @@ -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 '
Expand All @@ -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!')
Expand Down

0 comments on commit 5ee1a3a

Please sign in to comment.