pimutils / todoman

✅ A simple, standards-based, cli todo (aka: task) manager.
https://todoman.readthedocs.io
ISC License
483 stars 78 forks source link

Breaking changes in v4.0.0 #433

Closed WhyNotHugo closed 2 years ago

WhyNotHugo commented 3 years ago

The configuration format is changing with release 4.0.0. We currently depend on an unmaintained library for configuration. It's not currently in a working state, and while some distributions are patching it, setting up a clean environment is a bit non-trivial, and the situation will only degrade in future.

The changes in format are be subtle, and also come with an intention to add further extensibility in future. Configuration files will be plain python. If you don't know Python don't worry, you don't need to know Python.

I'll take my own config as a reference. The pre-4.0.0 format is:

[main]
path = ~/.local/share/calendars/*
time_format = '%H:%M'
default_list = todo
humanize = true
startable = true

The 4.0.0 version would look like this:

path = "~/.local/share/calendars/*"
time_format = "%H:%M"
default_list = "todo"
humanize = True
startable = True

Key differences:

That's basically it. This lets up drop the problematic dependency, and we don't actually need anything to read the config: it's just python code like the rest of todoman!

For those users who are python developers, you'll note this gives some interesting flexibility: you CAN add any custom python code into the config file. For example, you can defined the path programatically:

def get_path() -> str:
    ...

path = get_path

There are no limitations here, but if you break something, you get to keep both pieces.

agaAdams commented 3 years ago

I changed my old config file to ~/.config/todoman/todoman.conf

path = '~/.calendars/*'
date_format = '%d.%m.%y'
time_format = '%H:%M'
default_due = 0
default_list = "default"
dt_separator = "_"
humanize = True

Nonetheless I get a 'no configuration file found' error. What do I need to change?

WhyNotHugo commented 3 years ago

Whoops, that's not actually mentioned here! The config file is now called config.py, not todoman.conf. Placed in the same directory.

aleprovencio commented 3 years ago

In addition, the shell command does not seem available anymore

WhyNotHugo commented 3 years ago

The shell breakage is due an upstream issue; look like latest click version does not work with click_repl.

https://github.com/click-contrib/click-repl/issues/75

For the moment, downgrading to click<8.0 seems to be the only workaround.

agaAdams commented 3 years ago

Renaming the file worked. Thanks.

aleprovencio commented 3 years ago

The shell breakage is due an upstream issue; look like latest click version does not work with click_repl.

click-contrib/click-repl#75

For the moment, downgrading to click<8.0 seems to be the only workaround.

FYI, after updating my arch install this is not an issue to me anymore. :)

ig-perez commented 3 years ago

Thanks for maintaining this package!

Sadly after renaming the config file and updating its format I have a code issue:

configuration.py", line 227, in load_config
    spec = importlib.util.spec_from_file_location("config", path)
AttributeError: module 'importlib' has no attribute 'util'

My Python system version is 3.9.5. Any clue how to solve this?

Thanks!

WhyNotHugo commented 3 years ago

@ig-perez Is this still an issue? What OS is this? What's the output of python --version (just want to confirm that it's not using python2 by default)?

ig-perez commented 3 years ago

Hi @WhyNotHugo last time I checked it was still an issue, I have downgraded to v3.9.0 and all is working fine. My OS is Linux Fedora, the system's Python version is 3.8.8. and todoman is installed under it with $ pip install --user todoman

WhyNotHugo commented 3 years ago

What's the output of python -c "import importlib; importlib.util" and python --version?

ig-perez commented 3 years ago

This: image

WhyNotHugo commented 3 years ago

What's which python and head $(which todoman)

ig-perez commented 3 years ago

$ which python outputs /hdd/anaconda/bin/python $ head $(which todoman) outputs /usr/bin/which: no todoman in (/hdd/anaconda/bin:/hdd/anaconda/condabin:/home/ivan/.poetry/bin:/home/ivan/.pyenv/shims:/home/ivan/.poetry/bin:/home/ivan/.pyenv/bin:/home/ivan/.local/bin:/home/ivan/bin:/home/ivan/.poetry/bin:/home/ivan/.pyenv/shims:/home/ivan/.nvm/versions/node/v10.22.0/bin:/home/ivan/.poetry/bin:/home/ivan/.pyenv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/ivan/.local/bin:/home/ivan/.local/bin)

WhyNotHugo commented 3 years ago

Sorry, I meant which todo for that last one.

ig-perez commented 3 years ago

$ which todo outputs ~/.local/bin/todo but let me remind you due to the reported issue I downgrade the version to 3.9 as mentioned here :)

WhyNotHugo commented 3 years ago

What's head $(which todo).

I want to confirm it's really using the virutalenv and not the system python.

ig-perez commented 3 years ago

Please check here

WhyNotHugo commented 3 years ago

I mixed up my original question, I typed head $(which todoman), but I mean head $(which todo).

This prints the first few lines of the todoman binary. I want to double-check that the hashbang points to the python in your virtualenv, since todo uses a slightly non-standard hashbang.

ig-perez commented 3 years ago

This is the output for head $(which todo):

image

Now I recall I installed current version (todoman 3.9) within a Python 3.7 virtual env. since for higher versions only todoman v4 was available and it was not working for me.

But oddly when I run todo --version I get todoman, version 4.0.0 nevertheless I get 3.9 when I run pip list --user: image

WhyNotHugo commented 3 years ago

pip list --user will list user-installed backages (e.g.: in the user-default virtualenv). You can probably run this version using python -m todoman, and python -m todoman --version should print 4.0.0.

However, todo runs using the python/virtualenv in /home/ivan/.pyenv/versions/3.7.0, which apparently has 3.9.0 installed. I think you can confirm this by running /home/ivan/.pyenv/versions/3.7.0/bin/pip list.