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

Update for python-3.12 #168

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
taskwarrior-version: [2.5.0, 2.5.1, 2.5.3]
exclude:
# Taskwarriror 3.5.3 only supported on Python 3.7+.
- python-version: 3.5
taskwarrior-version: 2.5.3
- python-version: 3.6
taskwarrior-version: 2.5.3
python-version: [3.9, "3.10", 3.11, 3.12]
taskwarrior-version: [2.5.3, 2.6.2]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.python-version}}
Expand All @@ -25,7 +19,7 @@ jobs:
python-version: ${{matrix.python-version}}
- name: Install Taskwarrior ${{matrix.taskwarrior-version}}
run: |
sudo apt-get install -y python-dev cmake build-essential libgnutls28-dev uuid-dev gnutls-bin chrpath libssl-dev libfontconfig1-dev
sudo apt-get install -y python3-dev cmake build-essential libgnutls28-dev uuid-dev gnutls-bin chrpath libssl-dev libfontconfig1-dev
git clone https://github.com/GothenburgBitFactory/taskwarrior.git
cd taskwarrior
git checkout v${{matrix.taskwarrior-version}}
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-dateutil
pytz
kitchen
packaging
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@
REQUIREMENTS[category] = requirements

setup(name='taskw',
version='2.0.0',
version='2.1.0',
description="Python bindings for your taskwarrior database",
long_description=long_description,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Intended Audience :: Developers",
],
Expand Down
6 changes: 3 additions & 3 deletions taskw/fields/commaseparateduuid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from distutils.version import LooseVersion
from packaging.version import Version

import uuid

from .base import DirtyableList, Field


class CommaSeparatedUUIDField(Field):
version = LooseVersion('2.4')
version = Version('2.4')

def deserialize(self, value):
if not value:
Expand All @@ -27,7 +27,7 @@ def serialize(self, value):
if not hasattr(value, '__iter__'):
raise ValueError("Value must be list or tuple, not %r." % value)

if self.version < LooseVersion('2.5'):
if self.version < Version('2.5'):
return ','.join([str(v) for v in value])
else:
# We never hit this second code branch now. taskwarrior changed
Expand Down
4 changes: 2 additions & 2 deletions taskw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dateutil.tz
import pytz

from distutils.version import LooseVersion
from packaging.version import Version


DATE_FORMAT = '%Y%m%dT%H%M%SZ'
Expand Down Expand Up @@ -91,7 +91,7 @@ def encode_query(value, version, query=True):
])
)
else:
if k.endswith(".is") and version >= LooseVersion('2.4'):
if k.endswith(".is") and version >= Version('2.4'):
args.append(
'%s == "%s"' % (
k[:-3],
Expand Down
16 changes: 8 additions & 8 deletions taskw/warrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
import abc
import copy
from distutils.version import LooseVersion
from packaging.version import Version
import logging
import os
import re
Expand Down Expand Up @@ -432,13 +432,13 @@ def __init__(
self._marshal = marshal
self.config = TaskRc(config_filename, overrides=config_overrides)

if self.get_version() >= LooseVersion('2.4'):
if self.get_version() >= Version('2.4'):
self.DEFAULT_CONFIG_OVERRIDES['verbose'] = 'new-uuid'
# Combination of
# https://github.com/GothenburgBitFactory/taskwarrior/issues/1953
# and dictionaries random order may cause task add failures in
# Python versions before 3.7
if (self.get_version() >= LooseVersion('2.5.3') and
if (self.get_version() >= Version('2.5.3') and
sys.hexversion < 0x03070000):
warnings.once(
"Python < 3.7 with TaskWarrior => 2.5.3 is not suppoprted. "
Expand Down Expand Up @@ -553,7 +553,7 @@ def can_use(cls):
""" Returns true if runtime requirements of experimental mode are met
"""
try:
return cls.get_version() > LooseVersion('2')
return cls.get_version() > Version('2')
except FileNotFoundError:
# FileNotFound is raised if subprocess.Popen fails to find
# the executable.
Expand All @@ -570,10 +570,10 @@ def get_version(cls):
raise FileNotFoundError(
"Unable to find the 'task' command-line tool."
)
return LooseVersion(taskwarrior_version.decode())
return Version(taskwarrior_version.decode())

def sync(self, init=False):
if self.get_version() < LooseVersion('2.3'):
if self.get_version() < Version('2.3'):
raise UnsupportedVersionException(
"'sync' requires version 2.3 of taskwarrior or later."
)
Expand Down Expand Up @@ -682,7 +682,7 @@ def task_add(self, description, tags=None, **kw):

# With older versions of taskwarrior, you can specify whatever uuid you
# want when adding a task.
if self.get_version() < LooseVersion('2.4'):
if self.get_version() < Version('2.4'):
task['uuid'] = str(uuid.uuid4())
elif 'uuid' in task:
del task['uuid']
Expand All @@ -697,7 +697,7 @@ def task_add(self, description, tags=None, **kw):
# However, in 2.4 and later, you cannot specify whatever uuid you want
# when adding a task. Instead, you have to specify rc.verbose=new-uuid
# and then parse the assigned uuid out from stdout.
if self.get_version() >= LooseVersion('2.4'):
if self.get_version() >= Version('2.4'):
task['uuid'] = re.search(UUID_REGEX, stdout).group(0)

id, added_task = self.get_task(uuid=task['uuid'])
Expand Down
15 changes: 8 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[tox]
envlist = py{35,36,37,38}-tw{250,251} py{38}-tw{253}
envlist = py{39,310,311,312}-tw{253,262}
downloadcache = {toxworkdir}/_download/

[testenv]
basepython =
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
allowlist_externals =
{toxinidir}/.tox_build_taskwarrior.sh
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test_requirements.txt
setenv =
tw250: TASKWARRIOR=v2.5.0
tw251: TASKWARRIOR=v2.5.1
tw253: TASKWARRIOR=v2.5.3
tw262: TASKWARRIOR=v2.6.2
sitepackages = False
commands =
{toxinidir}/.tox_build_taskwarrior.sh "{envdir}" "{toxinidir}"
Expand Down