sphinx-contrib/apidoc

Call to `pbr.version.VersionInfo` raises exception on import

paulmelnikow opened this issue · 7 comments

I'm using this extension in Docker on a PaaS provider, Zeit Now, where I'm running documentation builds in response to pull requests.

I'm getting this exception when Sphinx starts up:

# Sphinx version: 1.8.1
# Python version: 2.7.15 (CPython)
# Docutils version: 0.14 
  File "/usr/local/lib/python2.7/site-packages/sphinx/registry.py", line 472, in load_extension
    mod = __import__(extname, None, None, ['setup'])
  File "/usr/local/lib/python2.7/site-packages/sphinxcontrib/apidoc/__init__.py", line 15, in <module>
    __version__ = pbr.version.VersionInfo('apidoc').version_string()
  File "/usr/local/lib/python2.7/site-packages/pbr/version.py", line 467, in version_string
    return self.semantic_version().brief_string()
  File "/usr/local/lib/python2.7/site-packages/pbr/version.py", line 462, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "/usr/local/lib/python2.7/site-packages/pbr/version.py", line 449, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "/usr/local/lib/python2.7/site-packages/pbr/packaging.py", line 839, in get_version
    name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name apidoc was given, but was not able to be found.

This line seems to be causing it:

https://github.com/sphinx-contrib/apidoc/blob/master/sphinxcontrib/apidoc/__init__.py#L15

The docker image is based on the official Python docker image. It doesn't do anything fancy, just running apt-get install and pip install and cleaning the cache. (I tried disabling the cache clean; no dice.)

Turning off the extension makes the problem go away.

I can't reproduce it locally, even in docker. Here's the Zeit build: https://zeit.co/lace/entente/jcdveazgph/logs

The last thing I tried was reinstalling sphinxcontrib-apidoc while the container was running. That didn't work either.

I'd really appreciate any ideas you might have!

Output of pip freeze:
alabaster==0.7.11
Babel==2.6.0
backports.functools-lru-cache==1.5
baiji==2.10.0
baiji-serialization==2.1.0
boto==2.49.0
cached-property==1.5.1
certifi==2018.8.24
chardet==3.0.4
Click==7.0
coloredlogs==10.0
CommonMark==0.5.4
cycler==0.10.0
docutils==0.14
env-flag==1.0.1
fasteners==0.14.1
futures==3.2.0
harrison==1.1.1
humanfriendly==4.16.1
idna==2.7
imagesize==1.1.0
Jinja2==2.10
kiwisolver==1.0.1
lxml==4.2.5
MarkupSafe==1.0
matplotlib==2.2.3
metabaiji-pod==1.0.7.post1
metablmath==1.2.5.post2
metabochumpy==0.67.6.post2
metabolace==1.1.8.dev1
metabolexecutor==20.0.post1
monotonic==1.5
nose2==0.5.0
numpy==1.15.2
packaging==18.0
pbr==4.2.0
plumbum==1.6.7
progressbar==2.5
property-manager==2.3.1
py-windows-exe==1.0.0
Pygments==2.2.0

setuptools version:

setuptools 40.2.0 from /usr/local/lib/python2.7/site-packages (Python 2.7)

How is the extension being installed in the image?

Thanks for the quick response!

In each case it's with pip.

When the base images are built, it's with pip install --upgrade -r ….

I've also tried reinstalling it when the final container is running, just before building the docs:

pip uninstall -y sphinxcontrib-apidoc
pip install sphinxcontrib-apidoc

That's very odd.

I don't see the plugin in the pip freeze output above. Was that output produced from a run where you had the plugin disabled? Or is that from before it is installed?

Is the source repo you're working with available to check out so I can try and reproduce this locally?

Argh, the log viewer doesn't seem to reliably show the entire output.

I trimmed things down and ran a smaller failing example. It won't build the complete docs because of missing dependencies, but Sphinx should exit without an error.

Here's what I'm seeing now:

alabaster==0.7.11
Babel==2.6.0
certifi==2018.8.24
chardet==3.0.4
Click==7.0
coloredlogs==10.0
CommonMark==0.5.4
docutils==0.14
fasteners==0.14.1
humanfriendly==4.16.1
idna==2.7
imagesize==1.1.0
Jinja2==2.10
MarkupSafe==1.0
metabolexecutor==20.0.post1
monotonic==1.5
packaging==18.0
pbr==4.2.0
property-manager==2.3.1
Pygments==2.2.0
pyparsing==2.2.2
pytz==2018.5
recommonmark==0.4.0
requests==2.19.1
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.8.1
sphinxcontrib-apidoc==0.2.1
sphinxcontrib-websupport==1.1.0
typing==3.6.6
urllib3==1.23
verboselogs==1.7
virtualenv==16.0.0

Build logs: https://zeit.co/lace/entente/ipsvqztnno

I still can't reproduce the problem on my machine if I run docker build -f Dockerfile ., though I wonder if it would be reproducible on a different mac or a Linux system…

Right now my best steps to reproduce are pretty sprawling, unfortunately:

  1. Hook up a Zeit Now account to a github repo
  2. Create a docker repo
  3. Update https://github.com/lace/entente/blob/debug-minimal/dev.py#L34-L35 to point to that repo
  4. Run ./dev.py docker-build debug-1 (or whatever tag you want to use)
  5. Run ./dev.py docker-push debug-1
  6. Update Dockerfile to point to that repo and tag
  7. Push to github to trigger Zeit deploy

Added: It works fine on another mac.

These are the most important bits:

The simplest command that reproduces the problem is:

python -c "import pbr.version; print pbr.version.VersionInfo('apidoc').version_string()"

Try applying the patch in #10 to see if that helps.

That does the trick. What an odd way for that to manifest! I appreciate your help!

For future record, this is a manifestation of https://bugs.launchpad.net/pbr/+bug/1758301