Skip to content
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

pip install'ed mock should not depend on command-line tools #314

Closed
dimaqq opened this issue Aug 13, 2015 · 10 comments
Closed

pip install'ed mock should not depend on command-line tools #314

dimaqq opened this issue Aug 13, 2015 · 10 comments

Comments

@dimaqq
Copy link

dimaqq commented Aug 13, 2015

I'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

@rbtcollins
Copy link
Member

That was a bug in pbr, which has since been fixed, and the release just made of the fix - pbr 1.5.0 should not have this bug.

@OpaVote
Copy link

OpaVote commented Oct 10, 2015

Hello,

I've got the latest versions of mock and pbr and I am getting the above error when I import mock. I reinstalled mock and pbr but that didn't help. Is there something else I need to do?

Python 2.7.8
mock (1.3.0)
pbr (1.8.1)

import unittest
from mock import patch, Mock, MagicMock

Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mock/init.py", line 2, in
import mock.mock as _mock
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mock/mock.py", line 71, in
_v = VersionInfo('mock').semantic_version()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pbr/version.py", line 452, in semantic_version
self._semantic = self._get_version_from_pkg_resources()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pbr/version.py", line 439, in _get_version_from_pkg_resources
result_string = packaging.get_version(self.package)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pbr/packaging.py", line 668, 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?

@OpaVote
Copy link

OpaVote commented Oct 11, 2015

This fixed it for me:
pip install --upgrade setuptools

@rbtcollins
Copy link
Member

@OpaVote what version of setuptools did you have before you upgraded?

@OpaVote
Copy link

OpaVote commented Oct 11, 2015

I had setuptools (0.6c11). Hadn't updated it in awhile. :)

@rbtcollins
Copy link
Member

Thanks. I've filed a bug on pbr (https://bugs.launchpad.net/pbr/+bug/1505007) about this failure mode.

@Andruso
Copy link

Andruso commented Oct 10, 2016

This still seems to be an issue and a pretty annoying one as it takes down the whole test-runner.

File "/Users/blah/blah.py", line 11, in <module>
    import mock
  File "/Library/Python/2.7/site-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "/Library/Python/2.7/site-packages/mock/mock.py", line 71, in <module>
    _v = VersionInfo('mock').semantic_version()
  File "/Library/Python/2.7/site-packages/pbr/version.py", line 460, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "/Library/Python/2.7/site-packages/pbr/version.py", line 447, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "/Library/Python/2.7/site-packages/pbr/packaging.py", line 725, 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?

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.

@radekholy24
Copy link

radekholy24 commented Oct 17, 2016

Same here:
Python 2.6.8
mock 2.0.0
setuptools 28.6.0
pbr 1.10.0
pip 8.1.2

Can we reopen this or should we file a new bug?

@rbtcollins
Copy link
Member

@Andruso I'm not sure what you mean when you say pbr is slowly dying - nor why its relevant: the bug you had with setuptools 28.3.0 is different to this bug, which appears to be related to setuptools 0.6c11 - a version from 2009. It seems reasonable that folk wanting to install packages from PyPI should use a less than 7 years old version of the build system for python packages.

@PyDeQ ssince you seem to have similar versions, please file a new bug.

@radekholy24
Copy link

radekholy24 commented Oct 20, 2016

@rbtcollins, #383
@Andruso, please take a look. If your steps differ, it might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants