From 2d68b94a46175613c04ebafea56852d02748e356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 24 Jan 2024 18:51:29 +0100 Subject: [PATCH 1/3] build: specify dependencies directly in setup.cfg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In tox v4, "reuse of environments" was disabled [1]. This is then later explained [2] to refer to exactly that thing which we were using for inheriting the dependencies from the top-level testenv all the way to the docs build. That's why the docs build in GitHub CI started failing. IMHO, The Correct Way™ of specifying what dependencies are used for which feature are the so-called "extra dependencies". Once they are in place, it is be possible to install gnpy via, e.g., `pip install oopt-gnpy[docs]`. However, this process is (as far as I can tell) incompatible with `requirements.txt`; all my attempts at using the standard dependency syntax in that file have failed for me. So, in order to make this happen, let's move all the dependencies from a more-or-less ad-hoc collection of files to this declarative approach right in setup.cfg. That way, the deps are listed on a single place, in a declarative manner, and as a result, the installation is now a trivial pip oneliner. As a result, one can also remove that duplication of dependencies in docs requirements. [1] https://tox.wiki/en/4.11.4/upgrading.html#reuse-of-environments [2] https://tox.wiki/en/4.11.4/upgrading.html#packaging-configuration-and-inheritance Change-Id: I34aa0c71e993b39e2b805a7de40e133b4d290318 Fixes: 47c89626 fix docs requirements --- .github/workflows/main.yml | 6 ++---- .readthedocs.yml | 1 - docs/requirements.txt | 12 ------------ requirements.txt | 11 ----------- setup.cfg | 32 ++++++++++++++++++++++++++++++++ tests/requirements.txt | 7 ------- tox.ini | 6 ++---- 7 files changed, 36 insertions(+), 39 deletions(-) delete mode 100644 docs/requirements.txt delete mode 100644 requirements.txt delete mode 100644 tests/requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 672cc45c7..e31d4c9bb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,8 +106,7 @@ jobs: with: python-version: ${{ matrix.python_version }} - run: | - pip install -r tests/requirements.txt - pip install --editable . + pip install --editable .[tests] pytest -vv strategy: fail-fast: false @@ -136,8 +135,7 @@ jobs: with: python-version: ${{ matrix.python_version }} - run: | - pip install -r tests/requirements.txt - pip install --editable . + pip install --editable .[tests] pytest -vv strategy: fail-fast: false diff --git a/.readthedocs.yml b/.readthedocs.yml index 0ee7e5c8d..aad577b4f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -2,4 +2,3 @@ build: image: latest python: version: 3.8 -requirements_file: docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 0059c8177..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -alabaster>=0.7.12,<1 -docutils>=0.17.1,<1 -matplotlib>=3.7.3,<4 -myst-parser>=0.16.1,<1 -networkx>=3.1,<4 -numpy>=1.24.4,<2 -Pygments>=2.11.2,<3 -rstcheck -scipy>=1.10.1,<2 -Sphinx>=5.3.0,<6 -sphinxcontrib-bibtex>=2.4.1,<3 -xlrd>=1.2.0,<2 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1c7a0043e..000000000 --- a/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -# matplotlib 3.8 removed support for Python 3.8 -matplotlib>=3.7.3,<4 -# networkx 3.2 removed support for Python 3.8 -networkx>=3.1,<4 -# numpy 1.25 removed support for Python 3.8 -numpy>=1.24.4,<2 -pbr>=6.0.0,<7 -# scipy 1.11 removed support for Python 3.8 -scipy>=1.10.1,<2 -# xlrd 2.x removed support for .xlsx, it's only .xls now -xlrd>=1.2.0,<2 diff --git a/setup.cfg b/setup.cfg index 029ddf53d..8069c3bb6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,3 +49,35 @@ console_scripts = gnpy-transmission-example = gnpy.tools.cli_examples:transmission_main_example gnpy-path-request = gnpy.tools.cli_examples:path_requests_run gnpy-convert-xls = gnpy.tools.convert:_do_convert + +[options] +install_requires = + # matplotlib 3.8 removed support for Python 3.8 + matplotlib>=3.7.3,<4 + # networkx 3.2 removed support for Python 3.8 + networkx>=3.1,<4 + # numpy 1.25 removed support for Python 3.8 + numpy>=1.24.4,<2 + pbr>=6.0.0,<7 + # scipy 1.11 removed support for Python 3.8 + scipy>=1.10.1,<2 + # xlrd 2.x removed support for .xlsx, it's only .xls now + xlrd>=1.2.0,<2 + +[options.extras_require] +tests = + build>=1.0.3,<2 + pytest>=7.4.3,<8 + # pandas 2.1 removed support for Python 3.8 + pandas>=2.0.3,<3 + # flake v6 killed the --diff option + flake8>=5.0.4,<6 + +docs = + alabaster>=0.7.12,<1 + docutils>=0.17.1,<1 + myst-parser>=0.16.1,<1 + Pygments>=2.11.2,<3 + rstcheck + Sphinx>=5.3.0,<6 + sphinxcontrib-bibtex>=2.4.1,<3 diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 72676e39d..000000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -build>=1.0.3,<2 -pytest>=7.4.3,<8 -# pandas 2.1 removed support for Python 3.8 -pandas>=2.0.3,<3 - -# flake v6 killed the --diff option -flake8>=5.0.4,<6 diff --git a/tox.ini b/tox.ini index 1b8c67dac..f3066da95 100644 --- a/tox.ini +++ b/tox.ini @@ -2,9 +2,8 @@ skipsdist = True [testenv] +extras = tests deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/tests/requirements.txt cover: pytest-cov linters: flake8 linters: pep8-naming @@ -22,8 +21,7 @@ commands = python -m build [testenv:docs] -deps = - -r{toxinidir}/docs/requirements.txt +extras = docs allowlist_externals = /bin/sh commands = From 3a733b1fd5483c6df031a553b0cbdb75b1ab9fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 24 Jan 2024 18:30:51 +0100 Subject: [PATCH 2/3] docs: try to unbreak the readthedocs.io build It was failing with a message: Config validation error in build.os. Value os not found. Apparently, the v2 config file is mandatory, so let's do that. Change-Id: I267d5314db026de532b2b6644f500d25de08e343 --- .readthedocs.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index aad577b4f..515a3c9bf 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,4 +1,15 @@ +version: 2 build: - image: latest + os: ubuntu-22.04 + tools: + python: "3.12" + python: - version: 3.8 + install: + - method: pip + path: . + extra_requirements: + - docs + +sphinx: + configuration: docs/conf.py From 5b6f8c60cf26ed0d4d419ca28b764fb7f7616a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 13 Mar 2024 18:42:23 +0100 Subject: [PATCH 3/3] docs: use the default theme on ReadTheDocs.org as well Historically, we've been using the RTD theme on the RTD site which hosts the docs for us, and a Sphinx-default, "Alabaster" theme for other docs builds. Doing that however started failing: Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 1096, in handle_page output = self.templates.render(templatename, ctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/readthedocs_ext/readthedocs.py", line 181, in rtd_render content = old_render(template, render_context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/jinja2glue.py", line 194, in render return self.environment.get_template(template).render(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code {%- extends "layout.html" %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/classic/layout.html", line 10, in top-level template code {%- extends "basic/layout.html" %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/default/../basic/layout.html", line 170, in top-level template code {%- block content %} File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/default/../basic/layout.html", line 189, in block 'content' {%- block sidebar2 %}{{ sidebar() }}{% endblock %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/default/../basic/layout.html", line 189, in block 'sidebar2' {%- block sidebar2 %}{{ sidebar() }}{% endblock %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/jinja2/sandbox.py", line 393, in call return __context.call(__obj, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/jinja2/runtime.py", line 777, in _invoke rv = self._func(*arguments) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/themes/default/../basic/layout.html", line 63, in template {%- include sidebartemplate %} ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/jinja2glue.py", line 215, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: about.html The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/cmd/build.py", line 281, in build_main app.build(args.force_all, args.filenames) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/application.py", line 347, in build self.builder.build_update() File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 310, in build_update self.build(to_build, File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 376, in build self.write(docnames, list(updated_docnames), method) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 571, in write self._write_serial(sorted(docnames)) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 581, in _write_serial self.write_doc(docname, doctree) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 672, in write_doc self.handle_page(docname, ctx, event_arg=doctree) File "/home/docs/checkouts/readthedocs.org/user_builds/gnpy/envs/499/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 1103, in handle_page raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") % sphinx.errors.ThemeError: An error happened in rendering the page about-project. Reason: TemplateNotFound('about.html') Theme error: An error happened in rendering the page about-project. Reason: TemplateNotFound('about.html') I have no clue what that means because we have never requested this `about.html`, nor do we reference that file from anywhere. Chances are that it's "just" some version pinning/compatibility issue, but hey -- why mess with that when there's a perfectly good default theme that we're using for other purposes already. As a side effect, this also solves that long-standing issue that Esther reported where the tables have overly long lines. Apparently, it's a theme-specific misfeature (readthedocs/sphinx_rtd_theme/#117), and the Alabaster one doesn't suffer from that. All hail alabaster! Change-Id: I857890f29f14b7c0f66bca201c9a9c1b1cbf8841 --- docs/conf.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5416461cc..b20001c66 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -84,18 +84,11 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get('READTHEDOCS') == 'True' -if on_rtd: - html_theme = 'default' - html_theme_options = { - 'logo_only': True, - } -else: - html_theme = 'alabaster' - html_theme_options = { - 'logo': 'images/GNPy-logo.png', - 'logo_name': False, - } +html_theme = 'alabaster' +html_theme_options = { + 'logo': 'images/GNPy-logo.png', + 'logo_name': False, +} html_logo = 'images/GNPy-logo.png'