pip install'ed mock should not depend on command-line tools
See original GitHub issueI’ve installed nose and mock into a chroot with some custom code and libraries.
i got following error when running nose:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/py_pkg/custom_src/test/test_something_custom.py", line 20, in <module>
from mock import patch
File "/usr/local/lib/python2.7/site-packages/mock/__init__.py", line 2, in <module>
import mock.mock as _mock
File "/usr/local/lib/python2.7/site-packages/mock/mock.py", line 71, in <module>
_v = VersionInfo('mock').semantic_version()
File "/usr/local/lib/python2.7/site-packages/pbr/version.py", line 452, in semantic_version
self._semantic = self._get_version_from_pkg_resources()
File "/usr/local/lib/python2.7/site-packages/pbr/version.py", line 439, 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 640, in get_version
raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?
It appears that mock brought in pbr dependency and that wants to examine something at runtime.
Perhaps a packaging kludge is needed (sdist in the error).
Or just remove it entirely when installing a fixed version from pypi.
Python-2.7.10
nose=1.3.7
mock install: Successfully installed funcsigs-0.4 mock-1.3.0 pbr-1.4.0
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
cli-mock - PyPI
This package provides two command line utilities: crecord and creplay. The former records the output (stdout and stderr) and the return code of...
Read more >Python/tox Install a dependency as editable - Stack Overflow
This example tells tox to install mock and pytest in to each virtualenv before running the tests. Tox will use pip to install...
Read more >Using Mock to test package builds - Fedora Project Wiki
This ensures that your BuildRequires lines are correct, that there are no missing dependencies, and that it builds cleanly. The Mock user ...
Read more >Understanding the Python Mock Object Library - Real Python
In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your...
Read more >Announcing Poetry 1.2.0 | Blog
Poetry will be installed using the Python interpreter the installer ... [tool.poetry.dev-dependencies] pytest = "^7.1.0" pytest-mock = "*".
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This fixed it for me: pip install --upgrade setuptools
This still seems to be an issue and a pretty annoying one as it takes down the whole test-runner.
Python 2.7.12 mock (2.0.0) setuptools (28.3.0) pbr (1.10.0) pip (8.1.2)
By now, it seems that PBR is slowly dying https://bugs.launchpad.net/pbr
Is it perhaps time to remove dependency on command-line tools as OP suggested?
I simply tried commenting out references to VersionInfo, version and version_info and the tests ran fine.