Skip to content

fix: pass env to language session #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@
]

html_baseurl = "https://www.pyopensci.org/python-package-guide/"
lang_selector_baseurl = "/python-package-guide/"
if not sphinx_env == "production":
# for links in language selector when developing locally
html_baseurl = "/"
lang_selector_baseurl = "/"

html_theme_options = {
"announcement": "<p><a href='https://www.pyopensci.org/about-peer-review/index.html'>We run peer review of scientific Python software. Learn more.</a></p>",
Expand Down Expand Up @@ -148,7 +149,7 @@
"github_version": "main",
"language": language,
"languages": build_languages,
"baseurl": html_baseurl,
"baseurl": lang_selector_baseurl,
}

# Add any paths that contain templates here, relative to this directory.
Expand Down
10 changes: 6 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def docs_test(session):
env={'SPHINX_ENV': 'production'})
# When building the guide with additional parameters, also build the translations in RELEASE_LANGUAGES
# with those same parameters.
session.notify("build-release-languages", [*TEST_PARAMETERS, *session.posargs])
session.notify("build-release-languages", ["production", *TEST_PARAMETERS, *session.posargs])

def _autobuild_cmd(posargs: list[str], output_dir = OUTPUT_DIR) -> list[str]:
cmd = [SPHINX_AUTO_BUILD, *BUILD_PARAMETERS, str(SOURCE_DIR), str(output_dir), *posargs]
Expand Down Expand Up @@ -274,7 +274,6 @@ def build_release_languages(session):
session.install("-e", ".")
for lang in RELEASE_LANGUAGES:
session.log(f"Building [{lang}] guide")
session.run(SPHINX_BUILD, *BUILD_PARAMETERS, "-D", f"language={lang}", ".", OUTPUT_DIR / lang, *session.posargs)
if lang == 'en':
out_dir = OUTPUT_DIR
else:
Expand Down Expand Up @@ -328,6 +327,9 @@ def _sphinx_env(session) -> str:
``SPHINX_ENV`` environment variable, defaulting to "development"
"""
if session.posargs and session.posargs[0] in SPHINX_ENVS:
return session.posargs.pop(0)
env = session.posargs.pop(0)
session.log(f"Using SPHINX_ENV={env} from posargs")
else:
return os.environ.get('SPHINX_ENV', 'development')
env = os.environ.get('SPHINX_ENV', 'development')
session.log(f"Using SPHINX_ENV={env} from os.environ")
return env
Loading