envvar-config-file
Note
This is a test of https://github.com/readthedocs/readthedocs.org/issues/6311#issuecomment-1324426604 but it seems it does not work…
Use a hacky way to define environment variables in the .readthedocs.yaml
.
These are the variables defined in the YAML:
- MYVAR1
None
- MYVAR2
None
- MYVAR3
None
1version: 2
2
3build:
4 os: ubuntu-22.04
5 tools:
6 python: "3"
7 jobs:
8 post_checkout:
9 - echo "export MYVAR1=myvar1" >> ~/.bash_profile
10 - echo "export MYVAR2=myvar2" >> ~/.bash_profile
11 - echo "export MYVAR3=myvar3" >> ~/.bash_profile
12 post_build:
13 - env
14
15sphinx:
16 configuration: docs/conf.py
17
18python:
19 install:
20 - requirements: requirements.txt
Sphinx configuration file used to build this docs (see full file),
1import os
2
3# Default settings
4project = 'Test Builds'
5extensions = [
6 'sphinx_autorun',
7]
8
9# Include all your settings here
10html_theme = 'sphinx_rtd_theme'
11
12
13myvar1 = os.environ.get('MYVAR1')
14myvar2 = os.environ.get('MYVAR2')
15myvar3 = os.environ.get('MYVAR3')
16
17rst_epilog = f"""
18.. |myvar1| replace:: {myvar1}
19.. |myvar2| replace:: {myvar2}
20.. |myvar3| replace:: {myvar3}
21"""
22
23
24
25
>>> # Build at
>>> import datetime
>>> datetime.datetime.utcnow() # UTC
datetime.datetime(2022, 11, 23, 9, 19, 57, 930608)