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

Fix python reference and imports #2

Merged
merged 2 commits into from
Dec 17, 2015
Merged

Fix python reference and imports #2

merged 2 commits into from
Dec 17, 2015

Conversation

tristil
Copy link
Contributor

@tristil tristil commented Dec 17, 2015

I wanted to use task.shift-recurrence but ran into these issues on MacOS.

  • Use env to select the right python executable. Fixes issue on MacOS
    with selecting the system python instead of the Homebrew python.
  • Existing imports did not work using the development version of tasklib
    mentioned in the README.

@tbabej
Copy link
Owner

tbabej commented Dec 17, 2015

The executable change I'm fine with, however, the imports seem to be working for me. I tested the issue in a new, clean virtualenv:

$ mkdir testenv
$ cd testenv/
$ virtualenv .

New python executable in ./bin/python2
Also creating executable in ./bin/python
Installing setuptools, pip...done.
$ bin/python2.7
Python 2.7.10 (default, Sep  8 2015, 17:20:17)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tasklib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tasklib
>>>

$ bin/pip2.7 install git+git://github.com/tbabej/tasklib@develop
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting git+git://github.com/tbabej/tasklib@develop
  Cloning git://github.com/tbabej/tasklib (to develop) to /tmp/pip-yICyT9-build
Collecting six==1.5.2 (from tasklib==0.10.0)
  Using cached six-1.5.2-py2.py3-none-any.whl
Collecting pytz (from tasklib==0.10.0)
  Downloading pytz-2015.7-py2.py3-none-any.whl (476kB)
    100% |################################| 479kB 317kB/s
Collecting tzlocal (from tasklib==0.10.0)
  Using cached tzlocal-1.2.tar.gz
Installing collected packages: tasklib, tzlocal, pytz, six
  Running setup.py install for tasklib
  Running setup.py install for tzlocal
Successfully installed pytz-2015.7 six-1.5.2 tasklib-0.10.0 tzlocal-1.2

$ bin/python2.7
Python 2.7.10 (default, Sep  8 2015, 17:20:17)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tasklib import TaskWarrior
>>>

Use env to select the right python executable. Fixes issue on MacOS
with selecting the system python instead of the Homebrew python.
@tristil
Copy link
Contributor Author

tristil commented Dec 17, 2015

Weird. I'm getting this locally:

 sh-3.2$ pip2.7 install --user git+git://github.com/tbabej/tasklib@develop --upgrade
Collecting git+git://github.com/tbabej/tasklib@develop
  Cloning git://github.com/tbabej/tasklib (to develop) to /var/folders/pm/64xc5hqn3qqc0xwrh04wzsjc0000gn/T/pip-cd4I4R-build
  Requirement already up-to-date: six==1.5.2 in /usr/local/lib/python2.7/site-packages (from tasklib==0.10.0)
  Requirement already up-to-date: pytz in /usr/local/lib/python2.7/site-packages (from tasklib==0.10.0)
  Requirement already up-to-date: tzlocal in /usr/local/lib/python2.7/site-packages (from tasklib==0.10.0)
  Installing collected packages: tasklib
    Running setup.py install for tasklib
    Successfully installed tasklib
sh-3.2$ task add test
Traceback (most recent call last):
  File "~/.task/hooks/on-add-pirate", line 7, in <module>
      from tasklib.task import TaskWarrior, Task
      ImportError: cannot import name TaskWarrior
      Hook Error: Expected feedback from a failing hook script.

I'll investigate on my own. In the meantime I dropped those changes and left just the executable change.

@tbabej
Copy link
Owner

tbabej commented Dec 17, 2015

I figured out where the difference is, I am importing:

>>> from tasklib import TaskWarrior

and you are (this is in the codebase)

>>> from tasklib.task import TaskWarrior

The code in the repository contains the wrong version.

Can you please get the import commit back up again, only not importing from backends directly, as TaskWarrior is exposed in the main module?

I think we'll be fine for merging then. If you'd prefer doing it in a different pull request, feel free to do so.

TaskWarrior and Task are available from the main tasklib module, not
tasklib.task.
@tristil
Copy link
Contributor Author

tristil commented Dec 17, 2015

@tbabej Sure. Commit added.

tbabej added a commit that referenced this pull request Dec 17, 2015
Fix python reference and imports
@tbabej tbabej merged commit 3ba79c2 into tbabej:master Dec 17, 2015
@tbabej
Copy link
Owner

tbabej commented Dec 17, 2015

Thanks!

@tristil
Copy link
Contributor Author

tristil commented Dec 17, 2015

np, thanks for task.shift-recurrence

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 this pull request may close these issues.

2 participants