Skip to content

Commit

Permalink
Basic untested implementation of plugin dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Oct 19, 2016
1 parent 8a60c09 commit cd80704
Showing 1 changed file with 20 additions and 0 deletions.
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():
subprocess.check_call((sys.executable, '-m', 'nikola', 'plugin', '-i', reqpath))
except subprocess.CalledProcessError:
LOGGER.error('Could not install a plugin.')
print('Contents of the requirements-plugins.txt file:\n')
with io.open(reqpath, '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 cd80704

Please sign in to comment.