Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7e5cbf

Browse files
rtobarcmaureir
andauthored
Ejecuta configuración de Sphinx de CPython de forma correcta (#3425)
Si bien la forma en que se ejecutaba e importaban la configuración deSphinx de CPython funciona, no es la mejor manera de hacerlo. Esto dadoque Sphinx inyecta algunos nombres globales al cual pueden acceder losarchivos conf.py, y que nuestro método no toma en cuenta.Este commit cambia la forma en que se importa y ejecuta el archivoconf.py de la documentación de CPython. En vez de añadirlo al path eimportarlo via "import" ahora se compilan los contenidos del archivo, yse ejecutan directamente con eval(). A este último se le entrega comocontexto el diccionario globals(), con lo que se logra el objetivo deque éste sea modificado por el código siendo ejecutado. Asimismo el usode globals() también logra hacer llegar cualquier valor que Sphinx hayainyectado en nuestro conf.py al conf.py de CPython.---------Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>Co-authored-by: Cristián Maureira-Fredes <cmaureir@users.noreply.github.com>
1 parentb9de17d commitd7e5cbf

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

‎conf.py‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
sys.path.append(os.path.abspath('cpython/Doc/tools/extensions'))
2222
sys.path.append(os.path.abspath('cpython/Doc/includes'))
2323

24-
# Import all the Sphinx settings from cpython
25-
# This import will trigger warnings on the 'Include/patchlevel.h'
26-
# not being found, because it execute the content of the whole file,
27-
# and there there is a local call to 'get_header_version' like the one
28-
# we have in a few lines.
29-
sys.path.insert(0,os.path.abspath('cpython/Doc'))
30-
fromconfimport*
24+
# Import all the Sphinx settings from cpython.
25+
# Warning: calling 'eval' and 'compile' is usually not recommended, but in this case
26+
# we are relying on the official sphinx configuration from cpython.
27+
cpython_sphinx_conf=Path(os.path.abspath('cpython/Doc/conf.py'))
28+
eval(compile(cpython_sphinx_conf.read_bytes(),str(cpython_sphinx_conf),"exec"),globals())
3129

3230
project='Python en Español'
3331

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp