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

Module path error when instantiating TimeTravel #55

Closed
thirtythreeforty opened this issue Aug 13, 2018 · 4 comments · Fixed by #56
Closed

Module path error when instantiating TimeTravel #55

thirtythreeforty opened this issue Aug 13, 2018 · 4 comments · Fixed by #56

Comments

@thirtythreeforty
Copy link

thirtythreeforty commented Aug 13, 2018

I would love to use this package, but I just can't get it to work. I've installed it with pip3 install time_travel and I have version 1.1.0. Unfortunately, the magic extensible patchers don't seem to work for me; I get strange errors related to the pkg_resources lookup. See below where I examine the failure in the debugger:

[ghilliard@farregard ~]$ ipython3
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.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]: %pdb
Automatic pdb calling has been turned ON

In [2]: from time_travel import TimeTravel

In [3]: tt = TimeTravel()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-3051fe43b841> in <module>()
----> 1 tt = TimeTravel()

/home/ghilliard/.local/lib/python3.6/site-packages/time_travel/time_travel.py in __init__(self, start_time, **kwargs)
     24         for patcher in pkg_resources.iter_entry_points(
     25                 group='time_travel.patchers'):
---> 26             patches.append(patcher.load())
     27 
     28         self.patches = [patcher(clock=self.clock, event_pool=self.event_pool,

/home/ghilliard/.local/lib/python3.6/site-packages/pkg_resources/__init__.py in load(self, require, *args, **kwargs)
   2319         if require:
   2320             self.require(*args, **kwargs)
-> 2321         return self.resolve()
   2322 
   2323     def resolve(self):

/home/ghilliard/.local/lib/python3.6/site-packages/pkg_resources/__init__.py in resolve(self)
   2325         Resolve the entry point from its module and attrs.
   2326         """
-> 2327         module = __import__(self.module_name, fromlist=['__name__'], level=0)
   2328         try:
   2329             return functools.reduce(getattr, self.attrs, module)

ModuleNotFoundError: No module named 'src'
> /home/ghilliard/.local/lib/python3.6/site-packages/pkg_resources/__init__.py(2327)resolve()
   2325         Resolve the entry point from its module and attrs.
   2326         """
-> 2327         module = __import__(self.module_name, fromlist=['__name__'], level=0)
   2328         try:
   2329             return functools.reduce(getattr, self.attrs, module)

ipdb> ^D


In [4]: import pkg_resources

In [5]: list(pkg_resources.iter_entry_points(group='time_travel.patchers'))
Out[5]: 
[EntryPoint.parse('datetime_patcher = src.time_travel.patchers.datetime_patcher:DatetimePatcher'),
 EntryPoint.parse('select_patcher = src.time_travel.patchers.select_patcher:SelectPatcher'),
 EntryPoint.parse('time_patcher = src.time_travel.patchers.time_patcher:TimePatcher')]

It looks like the src... module paths are only valid in the source tree. A cursory examination of the wheel package shows there is no such path in the distribution. The current unit tests don't catch this because they all run relative to the source tree, where the path does exist.

@snudler6
Copy link
Owner

Thank you very much for the bug.
I'll try to sit on it in the upcoming days to solve it

@thirtythreeforty
Copy link
Author

Thank you! I will let you know if I have any more trouble.

@snudler6
Copy link
Owner

No problem.
I'll finish the deploy PR, I've just pushed, and I'll release a new version to PyPI soon :)

@snudler6
Copy link
Owner

snudler6 commented Sep 4, 2018

At last succeed in pushing a new version to PyPI (should be easier next time around).
You can use it (v1.1.2) now 😄

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

Successfully merging a pull request may close this issue.

2 participants