Generate requirements.txt

This commit is contained in:
Stuart Axon 2018-11-15 00:12:20 +00:00
commit 59d9bf17c2

View file

@ -10,6 +10,8 @@ import sys
from jinja2 import Environment, FileSystemLoader
import pkg_resources
import pytz
try:
@ -45,7 +47,6 @@ _jinja_env = Environment(
trim_blocks=True,
)
_GITHUB_PAGES_BRANCHES = {
'personal': 'master',
'project': 'gh-pages'
@ -111,6 +112,7 @@ def decoding_strings(f):
else:
return out.decode(sys.stdin.encoding)
return out
return wrapper
@ -189,6 +191,14 @@ def ask(question, answer=str_compat, default=None, length=None):
'Argument `answer` must be str_compat, bool, or integer')
def write_requirements_txt():
distribution = pkg_resources.working_set.by_key['pelican']
with open(os.path.join(CONF['basedir'], 'requirements.txt'), 'w') as f:
f.write('{}\n'.format(distribution.as_requirement()))
for dependency in sorted(distribution.requires()):
f.write('{}\n'.format(dependency))
def ask_timezone(question, default, tzurl):
"""Prompt for time zone and validate input"""
lower_tz = [tz.lower() for tz in pytz.all_timezones]
@ -362,6 +372,8 @@ needed by Pelican.
except OSError as e:
print('Error: {0}'.format(e))
write_requirements_txt()
if automation:
try:
with codecs.open(os.path.join(CONF['basedir'], 'tasks.py'),