-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change matplotlib (+ numpy) to optional extra #493
Conversation
Related to useblocks#222 for matplotlib + depending on PR useblocks#493. Fixes useblocks#482 by adding plantuml as (optional) dependency. Open questions: - What to do about no_plantuml func, see diff - What is minimum plantuml version to allow? (currently latest = 0.22)
2a33f0e
to
60ed08d
Compare
Revisited this: Rebased the whole thing (without plantuml side), and tried to use it as a future user would. Created https://github.com/OverkillGuy/sphinx-needs-test, a sample repo from my personal cookiecutter (soon to be published), which first adds just sphinx-needs WITHOUT matplotlib, from my rebased PR. Then, in the Having not done this usage test before, I spotted that merely importing Overall I feel like this (finally) demonstrates that this PR is mature enough on the code side to at least be usable. I'd like to bring the PR into more thorough review. |
Thanks for the changes. We discussed also internally, if some functions should be moved to an external package, like sphinx-needs-analyzis or so. But no decision here. So I think this feature can be merged. Will do a review next week, as I have no possibility to do it right now. |
Anything that's blocking this? Willing to help if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the PR, just had one comment. And a rebase would be needed to resolve the conflicts.
Remove need for matplotlib by default (and NumPy, transitively), per useblocks#222. To enable matplotlib usage, install via pip install sphinxcontrib-needs[matplotlib] Add the note about needbar also needing matplotlib So far no change done in docs or import to handle missing features.
Needbar and needpie directives both need matplotlib, but could fail imports if the optional dependency is not installed. Accomodate failure by raising a specific and useful error message. Fix formatting Appease the pre-commit gods.
As discused in useblocks#222, the potential loss of feature that disabling matplotlib by default is not nice. To avoid that, add a new install extra meta-feature called "all", which will aggregate all extras one might want (currently just matplotlib). This becomes the new recommended way to install, so no loss of feature for those who use it, but allow the lighter option by disabling the all. Update docs accordingly (may be updating it a little strong). New docs entry for matplotlib/numpy support to align with plantuml.
Making a pass at rebasing right now, sending soon. |
Previous iteration raised on ANY import, which was the case when importing the module without really using it. Change the warning to only warn in case of USAGE of matplotlib, making it run OK in test project
Rebased locally, tests all red for now: Looks like a couple core places in the codebase are importing matplotlib since I made the PR. Investigating, hopefully this can be cordonned off as before, nothing major... |
Still using the on-use error via global var
Function now defined in single location "utils", taking in boolean, avoiding cross-file global issues. Use the newly relocated function in utils too
60ed08d
to
e0450fe
Compare
Right, that's me rebased, errors fixed (had to shuffle about the error message a bit), and tested, see procedure below. Ready for review! Test procedureUsing https://github.com/OverkillGuy/sphinx-needs-test. And check out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need guidance, see inline
Oversight: since moving the function to explicitly take parameter, forgot to pass the arg ALWAYS, some calls weren't updated, whoops
Applied all comments, ready for rereview. |
README.rst
Outdated
poetry add sphinx-needs | ||
poetry add sphinx-needs[all] | ||
# Lighter install without matplotlib = no pie charts | ||
poetry add sphinxcontrib-needs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it still say sphinxcontrib-needs here? Perhaps a merge error? The comment can be removed as well I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the sphinxcontrib-needs name, but if I remove the comment we have these 2 without explanation?
poetry add sphinx-needs[all]
poetry add sphinx-needs
That felt weird so I added that comment. Happy to remove, mostly felt the unexplained [all]
would add confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor suggestions. Overall I can confirm that it works as intended.
I ran pip install git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib
with the following output:
Output
Running command git clone --filter=blob:none --quiet https://github.com/OverkillGuy/sphinxcontrib-needs 'C:\Users\Benedikt\AppData\Local\Temp\pip-req-build-9lpgn4iz'
Running command git checkout -b optional-matplotlib --track origin/optional-matplotlib
branch 'optional-matplotlib' set up to track 'origin/optional-matplotlib'.
Switched to a new branch 'optional-matplotlib'
Resolved https://github.com/OverkillGuy/sphinxcontrib-needs to commit 61a3124e58521ed8201b4991ab93f61344d2982f
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting docutils>=0.15
Using cached docutils-0.20.1-py3-none-any.whl (572 kB)
Collecting jsonschema>=3.2.0
Downloading jsonschema-4.19.0-py3-none-any.whl (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.4/83.4 kB 4.9 MB/s eta 0:00:00
Collecting requests<3.0.0,>=2.25.1
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting requests-file<2.0.0,>=1.5.1
Downloading requests_file-1.5.1-py2.py3-none-any.whl (3.7 kB)
Collecting sphinx>=5.0
Downloading sphinx-7.1.2-py3-none-any.whl (3.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 10.1 MB/s eta 0:00:00
Collecting sphinx-data-viewer<0.2.0,>=0.1.1
Downloading sphinx-data-viewer-0.1.2.tar.gz (6.6 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting attrs>=22.2.0
Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting jsonschema-specifications>=2023.03.6
Using cached jsonschema_specifications-2023.7.1-py3-none-any.whl (17 kB)
Collecting referencing>=0.28.4
Using cached referencing-0.30.2-py3-none-any.whl (25 kB)
Collecting rpds-py>=0.7.1
Using cached rpds_py-0.9.2-cp311-none-win_amd64.whl (180 kB)
Collecting charset-normalizer<4,>=2
Using cached charset_normalizer-3.2.0-cp311-cp311-win_amd64.whl (96 kB)
Collecting idna<4,>=2.5
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1
Using cached urllib3-2.0.4-py3-none-any.whl (123 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting sphinxcontrib-applehelp
Downloading sphinxcontrib_applehelp-1.0.6-py3-none-any.whl (120 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.0/120.0 kB 7.3 MB/s eta 0:00:00
Collecting sphinxcontrib-devhelp
Downloading sphinxcontrib_devhelp-1.0.4-py3-none-any.whl (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.5/83.5 kB 4.6 MB/s eta 0:00:00
Collecting sphinxcontrib-jsmath
Using cached sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl (5.1 kB)
Collecting sphinxcontrib-htmlhelp>=2.0.0
Downloading sphinxcontrib_htmlhelp-2.0.3-py3-none-any.whl (99 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.2/99.2 kB 5.6 MB/s eta 0:00:00
Collecting sphinxcontrib-serializinghtml>=1.1.5
Downloading sphinxcontrib_serializinghtml-1.1.7-py3-none-any.whl (92 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 92.6/92.6 kB 5.1 MB/s eta 0:00:00
Collecting sphinxcontrib-qthelp
Downloading sphinxcontrib_qthelp-1.0.5-py3-none-any.whl (89 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.4/89.4 kB 4.9 MB/s eta 0:00:00
Collecting Jinja2>=3.0
Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting Pygments>=2.13
Downloading Pygments-2.16.1-py3-none-any.whl (1.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 8.2 MB/s eta 0:00:00
Collecting snowballstemmer>=2.0
Using cached snowballstemmer-2.2.0-py2.py3-none-any.whl (93 kB)
Collecting babel>=2.9
Downloading Babel-2.12.1-py3-none-any.whl (10.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 11.9 MB/s eta 0:00:00
Collecting alabaster<0.8,>=0.7
Using cached alabaster-0.7.13-py3-none-any.whl (13 kB)
Collecting imagesize>=1.3
Using cached imagesize-1.4.1-py2.py3-none-any.whl (8.8 kB)
Collecting packaging>=21.0
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting colorama>=0.4.5
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting MarkupSafe>=2.0
Using cached MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl (17 kB)
Building wheels for collected packages: sphinx-needs, sphinx-data-viewer
Building wheel for sphinx-needs (pyproject.toml) ... done
Created wheel for sphinx-needs: filename=sphinx_needs-1.2.2-py3-none-any.whl size=2608156 sha256=eeaaac6cf6ded86fd028f16d114e4182dddac99c8c4f5da0d6775a7cf5348e6a
Stored in directory: C:\Users\Benedikt\AppData\Local\Temp\pip-ephem-wheel-cache-xoehr0xh\wheels\f9\ed\aa\f0427f904af27765cd09bb067776fc0b5f82c01def41effb62
Building wheel for sphinx-data-viewer (pyproject.toml) ... done
Created wheel for sphinx-data-viewer: filename=sphinx_data_viewer-0.1.2-py3-none-any.whl size=7990 sha256=b81e006580dc6b314200118d65fa3ea3f8ffffeede098cfc94dff4e9e7dbba04
Stored in directory: c:\users\benedikt\appdata\local\pip\cache\wheels\34\d6\02\a485dd010dd8c3123cfa0a8bdae75aea24f31d3cc6993bb0e9
Successfully built sphinx-needs sphinx-data-viewer
Installing collected packages: snowballstemmer, urllib3, sphinxcontrib-jsmath, sphinx-data-viewer, six, rpds-py, Pygments, packaging, MarkupSafe, imagesize, idna, docutils, colorama, charset-normalizer, certifi, babel, attrs, alabaster, requests, referencing, Jinja2, requests-file, jsonschema-specifications, jsonschema, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, sphinx, sphinx-needs
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.3 Pygments-2.16.1 alabaster-0.7.13 attrs-23.1.0 babel-2.12.1 certifi-2023.7.22 charset-normalizer-3.2.0 colorama-0.4.6 docutils-0.20.1 idna-3.4 imagesize-1.4.1 jsonschema-4.19.0 jsonschema-specifications-2023.7.1 packaging-23.1 referencing-0.30.2 requests-2.31.0 requests-file-1.5.1 rpds-py-0.9.2 six-1.16.0 snowballstemmer-2.2.0 sphinx-7.1.2 sphinx-data-viewer-0.1.2 sphinx-needs-1.2.2 sphinxcontrib-applehelp-1.0.6 sphinxcontrib-devhelp-1.0.4 sphinxcontrib-htmlhelp-2.0.3 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.5 sphinxcontrib-serializinghtml-1.1.7 urllib3-2.0.4
Running pip install "sphinx-needs[all] @ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib"
then installs the now-optional dependency matplotlib and its dependencies:
Output
$ pip install "sphinx-needs[all] @ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib"
Collecting sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib
Cloning https://github.com/OverkillGuy/sphinxcontrib-needs (to revision optional-matplotlib) to c:\users\benedikt\appdata\local\temp\pip-install-bb312k1g\sphinx-needs_4104b84e5c534710845f459d9086a4c9
Running command git clone --filter=blob:none --quiet https://github.com/OverkillGuy/sphinxcontrib-needs 'C:\Users\Benedikt\AppData\Local\Temp\pip-install-bb312k1g\sphinx-needs_4104b84e5c534710845f459d9086a4c9'
Running command git checkout -b optional-matplotlib --track origin/optional-matplotlib
branch 'optional-matplotlib' set up to track 'origin/optional-matplotlib'.
Switched to a new branch 'optional-matplotlib'
Resolved https://github.com/OverkillGuy/sphinxcontrib-needs to commit 61a3124e58521ed8201b4991ab93f61344d2982f
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: docutils>=0.15 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.20.1)
Requirement already satisfied: jsonschema>=3.2.0 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (4.19.0)
Collecting matplotlib>=3.3.0
Downloading matplotlib-3.7.2-cp311-cp311-win_amd64.whl (7.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.5/7.5 MB 11.4 MB/s eta 0:00:00
Requirement already satisfied: requests<3.0.0,>=2.25.1 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.31.0)
Requirement already satisfied: requests-file<2.0.0,>=1.5.1 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.5.1)
Requirement already satisfied: sphinx>=5.0 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (7.1.2)
Requirement already satisfied: sphinx-data-viewer<0.2.0,>=0.1.1 in c:\users\benedikt\.venv\lib\site-packages (from sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.1.2)
Requirement already satisfied: attrs>=22.2.0 in c:\users\benedikt\.venv\lib\site-packages (from jsonschema>=3.2.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (23.1.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\users\benedikt\.venv\lib\site-packages (from jsonschema>=3.2.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2023.7.1)
Requirement already satisfied: referencing>=0.28.4 in c:\users\benedikt\.venv\lib\site-packages (from jsonschema>=3.2.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.30.2)
Requirement already satisfied: rpds-py>=0.7.1 in c:\users\benedikt\.venv\lib\site-packages (from jsonschema>=3.2.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.9.2)
Collecting contourpy>=1.0.1
Downloading contourpy-1.1.0-cp311-cp311-win_amd64.whl (470 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 470.9/470.9 kB 9.8 MB/s eta 0:00:00
Collecting cycler>=0.10
Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting fonttools>=4.22.0
Downloading fonttools-4.42.0-cp311-cp311-win_amd64.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 10.4 MB/s eta 0:00:00
Collecting kiwisolver>=1.0.1
Using cached kiwisolver-1.4.4-cp311-cp311-win_amd64.whl (55 kB)
Collecting numpy>=1.20
Downloading numpy-1.25.2-cp311-cp311-win_amd64.whl (15.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.5/15.5 MB 13.3 MB/s eta 0:00:00
Requirement already satisfied: packaging>=20.0 in c:\users\benedikt\.venv\lib\site-packages (from matplotlib>=3.3.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (23.1)
Collecting pillow>=6.2.0
Downloading Pillow-10.0.0-cp311-cp311-win_amd64.whl (2.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 11.4 MB/s eta 0:00:00
Collecting pyparsing<3.1,>=2.3.1
Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Collecting python-dateutil>=2.7
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\benedikt\.venv\lib\site-packages (from requests<3.0.0,>=2.25.1->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\benedikt\.venv\lib\site-packages (from requests<3.0.0,>=2.25.1->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\benedikt\.venv\lib\site-packages (from requests<3.0.0,>=2.25.1->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\benedikt\.venv\lib\site-packages (from requests<3.0.0,>=2.25.1->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2023.7.22)
Requirement already satisfied: six in c:\users\benedikt\.venv\lib\site-packages (from requests-file<2.0.0,>=1.5.1->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.16.0)
Requirement already satisfied: sphinxcontrib-applehelp in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.0.6)
Requirement already satisfied: sphinxcontrib-devhelp in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.0.4)
Requirement already satisfied: sphinxcontrib-jsmath in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.0.1)
Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.0 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.0.3)
Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.5 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.1.7)
Requirement already satisfied: sphinxcontrib-qthelp in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.0.5)
Requirement already satisfied: Jinja2>=3.0 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (3.1.2)
Requirement already satisfied: Pygments>=2.13 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.16.1)
Requirement already satisfied: snowballstemmer>=2.0 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.2.0)
Requirement already satisfied: babel>=2.9 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.12.1)
Requirement already satisfied: alabaster<0.8,>=0.7 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.7.13)
Requirement already satisfied: imagesize>=1.3 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (1.4.1)
Requirement already satisfied: colorama>=0.4.5 in c:\users\benedikt\.venv\lib\site-packages (from sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (0.4.6)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\benedikt\.venv\lib\site-packages (from Jinja2>=3.0->sphinx>=5.0->sphinx-needs[all]@ git+https://github.com/OverkillGuy/sphinxcontrib-needs@optional-matplotlib) (2.1.3)
Installing collected packages: python-dateutil, pyparsing, pillow, numpy, kiwisolver, fonttools, cycler, contourpy, matplotlib
Successfully installed contourpy-1.1.0 cycler-0.11.0 fonttools-4.42.0 kiwisolver-1.4.4 matplotlib-3.7.2 numpy-1.25.2 pillow-10.0.0 pyparsing-3.0.9 python-dateutil-2.8.2
Perhaps also revisit the checkboxes in the original PR comment at the top.
Good catch on last mention of sphinxcontrib-needs in PR. However grepping for the old name reveals a LOT of links pointing to previous github repo, previous docs URLs etc. Do we care? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my perspective. Ideally you'd have some test sas well that patch the matplotlib/numpy imports to ImportError, so you can be sure that everything except needpie/needbar works without those packages. Although not strictly necessary I guess. Edit: I see you already have a separate testing repo for that
time for @ubmarco to take a look
Good catch on last mention of sphinxcontrib-needs in PR.
However grepping for the old name reveals a LOT of links pointing to previous github repo, previous docs URLs etc. Do we care?
I only noticed because it was a changed line, it looks fine now. It's not in scope here to fix all mentions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @OverkillGuy & @sigma67,
thanks for this PR. From technical perspective I have no objection. Works as intended.
I also see this PR as a breaking change, so the version 2.0.0 is a good choice.
Wrt to the sphinx-needs release cycle, I'd like to merge it after the release of 1.3.0.
We want to release some pending smaller features into a release that is non-breaking. 1.3.0 will be released in the next days.
Let's then rebase this PR once more and finally merge it.
I'd sleep better if this PR would include a test case.
The current test cases should fail with this PR as nox does not install extras by default (it just includes them in the pip constraints file). They just don't as in the current noxfile, the docs dependencies are installed as well. And those include matplotlib
.
This should be improved so nox
separates the environments of docs build and test cases.
Then we can have test cases for needbar/needpie that use a dedicated nox env without the extras. For all other test cases we need to install those extras.
I'm afraid this refactoring burden falls onto this PR as it first introduces dependency splitting.
Hi @OverkillGuy, are you planning to tackle this or do you need help? |
Hey, I tried to add tests but I'm bumping against the existing layout that doesn't make much sense to me. Points I notice:
So, I need input on what to do:
Any advice on that? |
Heya @OverkillGuy as you can see I'm making quite a few changes at the moment 😅 but I'll circle back round and have a look at this PR soon cheers But yeh I agree the poetry/nox setup etc can be a bit of a pain lol |
Hi @OverkillGuy , I did you a favor and merged master, see over at: OverkillGuy#1 Regarding your questions I have some suggestions: Conditional test execution with matplotlib installed: use a pytest marker
Configure nox to do two separate testruns (with nox.parametrize):
I am not sure about the need for
to install everything in that file except matplotlib. Don't hesitate to ask in case of more questions. |
Optional matplotlib
Here's another idea if you want to be more specific. Instead of wrapping the entire function function with a mark and skipping it you can do this to ensure that an import importlib
from contextlib import nullcontext
import pytest
@pytest.fixture(scope="session", name="raises_on_missing_matplotlib")
def fixture_raises_on_missing_matplotlib():
try:
importlib.import_module("matplotlib")
return nullcontext()
except ImportError as err:
return pytest.raises(ImportError)
def test_something(raises_on_missing_matplotlib):
with raises_on_missing_matplotlib:
print() You'd still have to do the parametrize part to run with different environments, but you no longer need to modify the pytest call. |
It seems like we're not making any progress here. Shall I submit a draft with the proposed fixture? |
Sorry, things have come up, compounded with lack of vision on my side for the nox/testing, I'd appreciate a submission to get me going in the right direction yes! Apologies to make this a burden, I hoped to deliver this turnkey |
may be superceded by #1061 |
#1061 was merged, doing same. Thanks for all of your patience! |
Remove need for matplotlib by default (and NumPy, transitively), per #222.
To enable matplotlib usage, install via
Add a note about needbar/needpie also needing matplotlib in pyproject.toml (not visible till now)
Needbar and needpie directives both need matplotlib, but could fail imports if the optional dependency is not installed. Accomodate failure by raising a specific and useful error message via ImportError
Directive-specific docs updated with
versionchanged
warning about that dependency now being optional.High impact, high priority
Cosmetic, minor
needpie
for feature that needed it, but then discoveredneedbar
also uses it, and more may use it in future)nextversion
message in directives forversionchanged
blockdocs/changelog.rst
entry