Skip to content

Commit 7d00625

Browse files
authored
Reinstate support for PEP_REPO_PATH setting. (#1735)
* Reinstate support for PEP_REPO_PATH setting. This setting is referenced by PEP generation documentation in both this repository (at pythondotorg/docs/source/pep_generation.rst) and in the PEPs repository (at peps/README.rst). * Allow PEP_REPO_PATH setting to be set by environment variable. ...rather than by requiring a temporary source code change.
1 parent 9339f3f commit 7d00625

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

peps/management/commands/generate_pep_pages.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,19 @@ def verbose(msg):
5151
verbose("== Starting PEP page generation")
5252

5353
with ExitStack() as stack:
54-
verbose(f"== Fetching PEP artifact from {settings.PEP_ARTIFACT_URL}")
55-
temp_file = self.get_artifact_tarball(stack)
56-
if not temp_file:
57-
verbose("== No update to artifacts, we're done here!")
58-
return
59-
temp_dir = stack.enter_context(TemporaryDirectory())
60-
tar_ball = stack.enter_context(TarFile.open(fileobj=temp_file, mode='r:gz'))
61-
tar_ball.extractall(path=temp_dir, numeric_owner=False)
62-
63-
artifacts_path = os.path.join(temp_dir, 'peps')
54+
if settings.PEP_REPO_PATH is not None:
55+
artifacts_path = settings.PEP_REPO_PATH
56+
else:
57+
verbose(f"== Fetching PEP artifact from {settings.PEP_ARTIFACT_URL}")
58+
temp_file = self.get_artifact_tarball(stack)
59+
if not temp_file:
60+
verbose("== No update to artifacts, we're done here!")
61+
return
62+
temp_dir = stack.enter_context(TemporaryDirectory())
63+
tar_ball = stack.enter_context(TarFile.open(fileobj=temp_file, mode='r:gz'))
64+
tar_ball.extractall(path=temp_dir, numeric_owner=False)
65+
66+
artifacts_path = os.path.join(temp_dir, 'peps')
6467

6568
verbose("Generating RSS Feed")
6669
peps_rss = get_peps_rss(artifacts_path)

pydotorg/settings/local.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .base import *
2+
import os
23

34
DEBUG = True
45

@@ -24,8 +25,13 @@
2425

2526
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
2627

28+
# Set the local pep repository path to fetch PEPs from,
29+
# or none to fallback to the tarball specified by PEP_ARTIFACT_URL.
30+
PEP_REPO_PATH = os.environ.get('PEP_REPO_PATH', None) # directory path or None
31+
2732
# Set the path to where to fetch PEP artifacts from.
2833
# The value can be a local path or a remote URL.
34+
# Ignored if PEP_REPO_PATH is set.
2935
PEP_ARTIFACT_URL = os.path.join(BASE, 'peps/tests/peps.tar.gz')
3036

3137
# Use Dummy SASS compiler to avoid performance issues and remove the need to

0 commit comments

Comments
 (0)