jdillard / sphinx-sitemap

Sphinx extension to generate a multi-lingual, multi-version sitemap for HTML builds
https://sphinx-sitemap.readthedocs.io/en/latest/index.html
MIT License
55 stars 21 forks source link

2.5.0: pytest warnings #59

Open kloczek opened 1 year ago

kloczek commented 1 year ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-sitemap-2.5.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-sitemap-2.5.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ============================= test session starts ============================== platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-sitemap-2.5.0 collected 4 items tests/test_parallel_mode.py . [ 25%] tests/test_simple.py ... [100%] =============================== warnings summary =============================== tests/test_parallel_mode.py::test_parallel tests/test_parallel_mode.py::test_parallel /usr/lib64/python3.8/importlib/__init__.py:127: RemovedInSphinx80Warning: The alias 'sphinx.util.SkipProgressMessage' is deprecated, use 'sphinx.util.display.SkipProgressMessage' instead. Check CHANGES for Sphinx API modifications. return _bootstrap._gcd_import(name[level:], package, level) tests/test_parallel_mode.py::test_parallel tests/test_parallel_mode.py::test_parallel tests/test_parallel_mode.py::test_parallel tests/test_parallel_mode.py::test_parallel /usr/lib64/python3.8/importlib/__init__.py:127: RemovedInSphinx80Warning: The alias 'sphinx.util.progress_message' is deprecated, use 'sphinx.util.display.progress_message' instead. Check CHANGES for Sphinx API modifications. return _bootstrap._gcd_import(name[level:], package, level) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ======================== 4 passed, 6 warnings in 1.47s ========================= ```

Here is list of installed modules in build env

```console Package Version ----------------------------- ----------------- alabaster 0.7.12 appdirs 1.4.4 attrs 22.2.0 Babel 2.11.0 build 0.9.0 charset-normalizer 3.0.1 cssselect 1.1.0 distro 1.8.0 docutils 0.19 exceptiongroup 1.0.0 extras 1.0.0 fixtures 4.0.0 gpg 1.18.0-unknown idna 3.4 imagesize 1.4.1 importlib-metadata 6.0.0 iniconfig 2.0.0 Jinja2 3.1.2 libcomps 0.1.19 lxml 4.9.2 MarkupSafe 2.1.1 numpy 1.24.1 olefile 0.46 packaging 21.3 pbr 5.9.0 pep517 0.13.0 Pillow 9.4.0 pip 22.3.1 pluggy 1.0.0 Pygments 2.14.0 PyGObject 3.42.2 pyparsing 3.0.9 pytest 7.2.1 python-dateutil 2.8.2 pytz 2022.4 requests 2.28.2 rpm 4.17.0 scour 0.38.2 setuptools 65.6.3 six 1.16.0 snowballstemmer 2.2.0 Sphinx 6.1.3 sphinx_contributors 0.2.7 sphinxcontrib-applehelp 1.0.2.dev20221204 sphinxcontrib-devhelp 1.0.2.dev20221204 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20230128 sphinxcontrib-qthelp 1.0.3.dev20230128 sphinxcontrib-serializinghtml 1.1.5 sphinxemoji 0.2.0 testtools 2.5.0 tomli 2.0.1 urllib3 1.26.12 wheel 0.38.4 zipp 3.11.0 ```

I also have two small patches which I'm using during build my package with sphinx documentation as man page. Beow patch alows build socumetation without have installed sphinx-sitemap module using straight source tree

--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,9 +11,13 @@
 # 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.
 #
+import os
+import sys
 import re
 import subprocess

+sys.path.insert(0, os.path.abspath(".."))
+
 # -- Project information -----------------------------------------------------

 project = "Sphinx Sitemap"

Sesond patch allows obtain module version not from git tag but from module version

--- a/docs/conf.py
+++ b/docs/conf.py
@@ -15,22 +15,18 @@
 import sys
 import re
 import subprocess
-
 sys.path.insert(0, os.path.abspath(".."))

+import sphinx_sitemap
+
 # -- Project information -----------------------------------------------------

 project = "Sphinx Sitemap"
 copyright = "Jared Dillard"
 author = "Jared Dillard"

-# check if the current commit is tagged as a release (vX.Y.Z)
-GIT_TAG_OUTPUT = subprocess.check_output(["git", "tag", "--points-at", "HEAD"])
-current_tag = GIT_TAG_OUTPUT.decode().strip()
-if re.match(r"^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$", current_tag):
-    version = current_tag
-else:
-    version = "latest"
+version = sphinx_sitemap.__version__
+
 # The full version, including alpha/beta/rc tags
 release = ""

Second on is usuefull on build module out of autogenerated fron git tag tar ball which has no .git metadata. With abpve patches is possible to generate documentation by:

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v6.1.3
making output directory... done
loading intersphinx inventory from https://www.sphinx-doc.org/en/master/objects.inv...
building [mo]: targets for 0 po files that are out of date
writing output...
building [man]: all manpages
updating environment: [new config] 7 added, 0 changed, 0 removed
reading sources... [ 14%] advanced-configuration
reading sources... [ 28%] changelog
reading sources... [ 42%] configuration-values
reading sources... [ 57%] contributing
reading sources... [ 71%] getting-started
reading sources... [ 85%] index
reading sources... [100%] search-optimization

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-sphinx-sitemap.3 { getting-started advanced-configuration search-optimization configuration-values contributing changelog } done
sphinx-sitemap: No pages generated for sitemap.xml
build succeeded.

Feel free to commit those patch or let me know if you want them as PRs.

jdillard commented 1 year ago

That warning looks like it was recently fixed in sphinxcontrib-applehelp 1.3.0 and you have 1.0.2.dev20221204.

A PR for the first patch would be great! I guess sphinx-sitemap should come out of docs/requirements.txt as well?

For the second patch, how about trying the Git method and if that fails, default to using sphinx_sitemap.__version__. Otherwise, the latest version of the online docs will always show the version as the most recent release, which may not be accurate if the docs contain changes for a pending release.

kloczek commented 1 year ago

OK .. one sec I'll try upgrae my rpm package with sphinxcontrib-applehelp. Will back shortly :tong

or the second patch, how about trying the Git method and if that fails, default to using sphinx_sitemap.version. Otherwise, the latest version of the online docs will always show the version as the most recent release, which may not be accurate if the docs contain changes for a pending release.

If you see some way how to build with git and otherwise with module sphinx_sitemap.__version__ feel free to implemnt that šŸ˜› If you don't like that patch I'll keep it in my build because I need to buold documentation without git metadata šŸ˜„

jdillard commented 1 year ago

If you see some way how to build with git and otherwise with module sphinx_sitemap.__version__ feel free to implemnt that

I'd have to test it out, but I was thinking something like:

try:
    GIT_TAG_OUTPUT = subprocess.check_output(...)
    [...]
except subprocess.CalledProcessError as e:
    print(e) # some sort of fallback message
    version = sphinx_sitemap.__version__