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

MDAnalysisTests raises exception when imported #1301

Closed
orbeckst opened this issue Apr 10, 2017 · 6 comments
Closed

MDAnalysisTests raises exception when imported #1301

orbeckst opened this issue Apr 10, 2017 · 6 comments

Comments

@orbeckst
Copy link
Member

Expected behaviour

import MDAnalysisTests

and

import MDAnalysis.tests

should import (and make eg files available in datafiles.

Actual behaviour

Both imports fail with

In [3]: import MDAnalysisTests
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-3-52912a4f0416> in <module>()
----> 1 import MDAnalysisTests

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/MDAnalysisTests/__init__.py in <module>()
    141     pass
    142
--> 143 from MDAnalysisTests.util import (
    144     block_import,
    145     executable_not_found,

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/MDAnalysisTests/util.py in <module>()
     37 from functools import wraps
     38 import importlib
---> 39 import mock
     40 import os
     41

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/mock/__init__.py in <module>()
      1 from __future__ import absolute_import
----> 2 import mock.mock as _mock
      3 from mock.mock import *
      4 __all__ = _mock.__all__
      5 #import mock.mock as _mock

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/mock/mock.py in <module>()
     69 from pbr.version import VersionInfo
     70
---> 71 _v = VersionInfo('mock').semantic_version()
     72 __version__ = _v.release_string()
     73 version_info = _v.version_tuple()

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/version.pyc in semantic_version(self)
    458         """Return the SemanticVersion object for this version."""
    459         if self._semantic is None:
--> 460             self._semantic = self._get_version_from_pkg_resources()
    461         return self._semantic
    462

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/version.pyc in _get_version_from_pkg_resources(self)
    445             # installed into anything. Revert to setup-time logic.
    446             from pbr import packaging
--> 447             result_string = packaging.get_version(self.package)
    448         return SemanticVersion.from_pip_string(result_string)
    449

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/packaging.pyc in get_version(package_name, pre_version)
    748                     " to pbr.version.VersionInfo. Project name {name} was"
    749                     " given, but was not able to be found.".format(
--> 750                         name=package_name))
    751
    752

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 mock was given, but was not able to be found.

Code to reproduce the behaviour

import MDAnalysisTests

Currently version of MDAnalysis:

(run python -c "import MDAnalysis as mda; print(mda.__version__)")

0.16.0 (pip upgraded in a virtualenv)

@orbeckst orbeckst added this to the 0.16.x milestone Apr 10, 2017
@orbeckst
Copy link
Member Author

More precisely, this appears to be an issue with mock (maybe my installation?)

import mock

gives

In [5]: import mock
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-5-cfb57b0376ce> in <module>()
----> 1 import mock

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/mock/__init__.py in <module>()
      1 from __future__ import absolute_import
----> 2 import mock.mock as _mock
      3 from mock.mock import *
      4 __all__ = _mock.__all__
      5 #import mock.mock as _mock

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/mock/mock.py in <module>()
     69 from pbr.version import VersionInfo
     70
---> 71 _v = VersionInfo('mock').semantic_version()
     72 __version__ = _v.release_string()
     73 version_info = _v.version_tuple()

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/version.pyc in semantic_version(self)
    458         """Return the SemanticVersion object for this version."""
    459         if self._semantic is None:
--> 460             self._semantic = self._get_version_from_pkg_resources()
    461         return self._semantic
    462

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/version.pyc in _get_version_from_pkg_resources(self)
    445             # installed into anything. Revert to setup-time logic.
    446             from pbr import packaging
--> 447             result_string = packaging.get_version(self.package)
    448         return SemanticVersion.from_pip_string(result_string)
    449

/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/pbr/packaging.pyc in get_version(package_name, pre_version)
    748                     " to pbr.version.VersionInfo. Project name {name} was"
    749                     " given, but was not able to be found.".format(
--> 750                         name=package_name))
    751
    752

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 mock was given, but was not able to be found.

@orbeckst
Copy link
Member Author

FYI: I completely nuked the virtualenv and rebuild it from scratch. Still same error.

This is annoying because it means than none of the tutorials work at the moment, they all rely on the user using the tests trajectories.

@orbeckst
Copy link
Member Author

@orbeckst
Copy link
Member Author

Possibly similar issue as testing-cabal/mock#402

@orbeckst
Copy link
Member Author

Well... this seems to be an issue with me using ipython in a virtual env: In Python itself:

Python 2.7.13 (default, Dec 23 2016, 05:05:16)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MDAnalysisTests
>>> import MDAnalysisTests.datafiles
>>> print MDAnalysisTests.datafiles.PSF
/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/MDAnalysisTests/data/adk.psf

When I install ipython into the virtualenv and make sure that I use the correct one then it works

(mda_clean) yngvi:issue-1133 oliver$ /Users/oliver/.virtualenvs/mda_clean/bin/ipython2
[TerminalIPythonApp] WARNING | Config option `ignore_old_config` not recognized by `TerminalIPythonApp`.
Python 2.7.13 (default, Dec 23 2016, 05:05:16)
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import MDAnalysisTests

In [2]: import MDAnalysisTests.datafiles

In [3]: print MDAnalysisTests.datafiles.PSF
/Users/oliver/.virtualenvs/mda_clean/lib/python2.7/site-packages/MDAnalysisTests/data/adk.psf

@kain88-de
Copy link
Member

Oh yeah ipython can be tricky with virtual envs. It will always pick your global Python installation unless it is installed in the virtual env.

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

No branches or pull requests

2 participants