File: Ensure-py_ecc-modules-are-discoverable-by-Sphinx-autodoc.patch

package info (click to toggle)
python-py-ecc 8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 780 kB
  • sloc: python: 4,893; makefile: 237
file content (45 lines) | stat: -rw-r--r-- 3,209 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <otto@debian.org>
Date: Thu, 18 Sep 2025 23:38:55 +0000
Subject: Ensure `py_ecc` modules are discoverable by Sphinx autodoc

Explicitly define the project's root directory to ensure Sphinx will
correctly import `py_ecc` modules for API documentation, eliminating
build warnings such as:

    WARNING: autodoc: failed to import module 'bls.ciphersuites' from module 'py_ecc'; the following exception was raised:
    ['Traceback (most recent call last):\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 269, in import_object\n    module = import_module(modname, try_reload=True)\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 172, in import_module\n    raise ModuleNotFoundError(msg, name=modname)  # NoQA: TRY301\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', "ModuleNotFoundError: No module named 'py_ecc'\n"] [autodoc.import_object]
    WARNING: autodoc: failed to import module 'bls.constants' from module 'py_ecc'; the following exception was raised:
    ['Traceback (most recent call last):\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 269, in import_object\n    module = import_module(modname, try_reload=True)\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 172, in import_module\n    raise ModuleNotFoundError(msg, name=modname)  # NoQA: TRY301\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', "ModuleNotFoundError: No module named 'py_ecc'\n"] [autodoc.import_object]
    WARNING: autodoc: failed to import module 'bls.g2_primitives' from module 'py_ecc'; the following exception was raised:
    ['Traceback (most recent call last):\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 269, in import_object\n    module = import_module(modname, try_reload=True)\n', '  File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 172, in import_module\n    raise ModuleNotFoundError(msg, name=modname)  # NoQA: TRY301\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', "ModuleNotFoundError: No module named 'py_ecc'\n"] [autodoc.import_object]
    ...

Additionally, correct the `DIR` variable assignment to not use quotes
but to evaluate the `__file__` variable.

Forwarded: no
---
 docs/conf.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index cbec1e0..03725e3 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,11 +13,13 @@
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-# sys.path.insert(0, os.path.abspath('.'))
-
 import os
+import sys
+
+# Add the project root to sys.path so Sphinx can find the py_ecc package
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
 
-DIR = os.path.dirname("__file__")
+DIR = os.path.dirname(__file__) # Use __file__ directly
 with open(os.path.join(DIR, "../setup.py"), "r") as f:
     for line in f:
         if "version=" in line: