Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

Just run for example `sphinx-build -n -T -b man doc/source build/sphinx/man`

Issue Description

Looks like it is not possible to build module documebation and sphinx-build crashes with call trace.

[tkloczko@pers-jacek pandas-2.0.1]$ PYTHONPATH=$PWD/build/$(cd build; ls -d1 lib*) sphinx-build -n -T -b man doc/source build/sphinx/man
Running Sphinx v6.2.0

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 229, in __init__
    self.setup_extension(extension)
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 404, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 442, in load_extension
    mod = import_module(extname)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/tkloczko/rpmbuild/BUILD/pandas-2.0.1/doc/sphinxext/contributors.py", line 17, in <module>
    from announce import build_components
  File "/home/tkloczko/rpmbuild/BUILD/pandas-2.0.1/doc/sphinxext/announce.py", line 46, in <module>
    this_repo = Repo(os.path.join(os.path.dirname(__file__), "..", ".."))
  File "/usr/lib/python3.8/site-packages/git/repo/base.py", line 282, in __init__
    self.working_dir: Optional[PathLike] = self._working_tree_dir or self.common_dir
  File "/usr/lib/python3.8/site-packages/git/repo/base.py", line 363, in common_dir
    raise InvalidGitRepositoryError()
git.exc.InvalidGitRepositoryError

Exception occurred:
  File "/usr/lib/python3.8/site-packages/git/repo/base.py", line 363, in common_dir
    raise InvalidGitRepositoryError()
git.exc.InvalidGitRepositoryError
The full traceback has been saved in /tmp/sphinx-err-ww2yorv9.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

[tkloczko@pers-jacek pandas-2.0.1]$ cat /tmp/sphinx-err-ww2yorv9.log
# Platform:         linux; (Linux-6.1.10-200.fc37.x86_64-x86_64-with-glibc2.34)
# Sphinx version:   6.2.0
# Python version:   3.8.16 (CPython)
# Docutils version: 0.19
# Jinja2 version:   3.1.2
# Pygments version: 2.15.1

# Last messages:


# Loaded extensions:


# Traceback:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 229, in __init__
    self.setup_extension(extension)
  File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 404, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/lib/python3.8/site-packages/sphinx/registry.py", line 442, in load_extension
    mod = import_module(extname)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/tkloczko/rpmbuild/BUILD/pandas-2.0.1/doc/sphinxext/contributors.py", line 17, in <module>
    from announce import build_components
  File "/home/tkloczko/rpmbuild/BUILD/pandas-2.0.1/doc/sphinxext/announce.py", line 46, in <module>
    this_repo = Repo(os.path.join(os.path.dirname(__file__), "..", ".."))
  File "/usr/lib/python3.8/site-packages/git/repo/base.py", line 282, in __init__
    self.working_dir: Optional[PathLike] = self._working_tree_dir or self.common_dir
  File "/usr/lib/python3.8/site-packages/git/repo/base.py", line 363, in common_dir
    raise InvalidGitRepositoryError()
git.exc.InvalidGitRepositoryError

Expected Behavior

sphinx-build should render documentation in requested format.

Installed Versions

2.0.1

Comment From: MarcoGorelli

thanks for the issue

as explained in previous issues: the supported way to build the docs (and run tests, and anything else) is explained here: https://pandas.pydata.org/docs/dev/development/contributing_documentation.html

if you're trying to do something unsupported like

PYTHONPATH=$PWD/build/$(cd build; ls -d1 lib*) sphinx-build -n -T -b man doc/source build/sphinx/man

then that's fine, you're welcome to try it out, but it's also up to you to debug

closing then

Comment From: kloczek

Using make.py it fails as well. Did you try to use latest sphinx? 🤔

Comment From: kloczek

Coud please confitm that ypu are able to build documemtation using lates sphinx 6.2.1? 🤔

Comment From: MarcoGorelli

right, looks like it's 4.5.0 in CI, thanks https://github.com/pandas-dev/pandas/actions/runs/4801114969/jobs/8542906814

Comment From: phofl

Closing, one of our dependencies pins sphinx to <5, so failures are not unexpected