From bab26e28f0ee597f723e0cab6904e6d8e5e344dc Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Tue, 14 Oct 2025 20:32:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Ejecuta=20configuraci=C3=B3n=20de=20Sphinx?= =?UTF-8?q?=20de=20CPython=20de=20forma=20correcta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si bien la forma en que se ejecutaba e importaban la configuración de Sphinx de CPython funciona, no es la mejor manera de hacerlo. Esto dado que Sphinx inyecta algunos nombres globales al cual pueden acceder los archivos conf.py, y que nuestro método no toma en cuenta. Este commit cambia la forma en que se importa y ejecuta el archivo conf.py de la documentación de CPython. En vez de añadirlo al path e importarlo via "import" ahora se compilan los contenidos del archivo, y se ejecutan directamente con eval(). A este último se le entrega como contexto el diccionario globals(), con lo que se logra el objetivo de que éste sea modificado por el código siendo ejecutado. Asimismo el uso de globals() también logra hacer llegar cualquier valor que Sphinx haya inyectado en nuestro conf.py al conf.py de CPython. Signed-off-by: Rodrigo Tobar --- conf.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/conf.py b/conf.py index 9a9557ae0c..22af597169 100644 --- a/conf.py +++ b/conf.py @@ -22,12 +22,8 @@ sys.path.append(os.path.abspath('cpython/Doc/includes')) # Import all the Sphinx settings from cpython -# This import will trigger warnings on the 'Include/patchlevel.h' -# not being found, because it execute the content of the whole file, -# and there there is a local call to 'get_header_version' like the one -# we have in a few lines. -sys.path.insert(0, os.path.abspath('cpython/Doc')) -from conf import * +cpython_sphinx_conf = Path(os.path.abspath('cpython/Doc/conf.py')) +eval(compile(cpython_sphinx_conf.read_bytes(), str(cpython_sphinx_conf), "exec"), globals()) project = 'Python en Español' From fb474f2bd4ff1101a9999ff60ce6a4e4b9951453 Mon Sep 17 00:00:00 2001 From: rtobar Date: Tue, 14 Oct 2025 23:12:38 +0800 Subject: [PATCH 2/2] Update conf.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cristián Maureira-Fredes --- conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 22af597169..a267d02a07 100644 --- a/conf.py +++ b/conf.py @@ -21,7 +21,9 @@ sys.path.append(os.path.abspath('cpython/Doc/tools/extensions')) sys.path.append(os.path.abspath('cpython/Doc/includes')) -# Import all the Sphinx settings from cpython +# Import all the Sphinx settings from cpython. +# Warning: calling 'eval' and 'compile' is usually not recommended, but in this case +# we are relying on the official sphinx configuration from cpython. cpython_sphinx_conf = Path(os.path.abspath('cpython/Doc/conf.py')) eval(compile(cpython_sphinx_conf.read_bytes(), str(cpython_sphinx_conf), "exec"), globals())