mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Update pelican_quickstart.py
Have pelican_quickstart generate a requirements.txt
This commit is contained in:
parent
940d4534a1
commit
c01eb8e6ef
1 changed files with 14 additions and 3 deletions
|
|
@ -8,9 +8,9 @@ import locale
|
|||
import os
|
||||
import sys
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import pkg_resources
|
||||
import pytz
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
try:
|
||||
import readline # NOQA
|
||||
|
|
@ -19,6 +19,7 @@ except ImportError:
|
|||
|
||||
try:
|
||||
import tzlocal
|
||||
|
||||
_DEFAULT_TIMEZONE = tzlocal.get_localzone().zone
|
||||
except ImportError:
|
||||
_DEFAULT_TIMEZONE = 'Europe/Paris'
|
||||
|
|
@ -45,7 +46,6 @@ _jinja_env = Environment(
|
|||
trim_blocks=True,
|
||||
)
|
||||
|
||||
|
||||
_GITHUB_PAGES_BRANCHES = {
|
||||
'personal': 'master',
|
||||
'project': 'gh-pages'
|
||||
|
|
@ -111,6 +111,7 @@ def decoding_strings(f):
|
|||
else:
|
||||
return out.decode(sys.stdin.encoding)
|
||||
return out
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
|
|
@ -189,6 +190,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]
|
||||
|
|
@ -361,6 +370,8 @@ needed by Pelican.
|
|||
fd.close()
|
||||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
|
||||
write_requirements_txt()
|
||||
|
||||
if automation:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue