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

Use setuptools-scm / pyproject.toml (modern packaging) #364

Merged
merged 1 commit into from
Dec 19, 2023
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ tests/conf_private.py
.tox
.eggs
.venv
caldav/_version.py
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This project should more or less adhere to [Semantic Versioning](https://semver.

* Initial work at integrating typing information. Details in https://github.com/python-caldav/caldav/pull/358
* Remove dependency on pytz. Details in https://github.com/python-caldav/caldav/issues/231
* Use setuptools-scm / pyproject.toml (modern packaging). Details in https://github.com/python-caldav/caldav/pull/364

## [1.3.9] - 2023-12-12

Expand Down
12 changes: 9 additions & 3 deletions RELEASE-HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ I have no clue on the proper procedures for doing releases, and I keep on doing
* For minor and major releases, look through the github issues, anything urgent there that should be fixed prior to doing a new release?
* Write up some release notes. (I typically keep a short summary of the changes in the CHANGELOG, and use that as the release notes).
* Verify that we're on the right branch - `git checkout master`. (`master` may not always be right - sometimes we may want to use a dedicated branch connected to the release-series, i.e. `v1.3`)
* Change the version number in `caldav/__init__.py`.
* Commit the changes (typically `CHANGELOG.md`, `__init__.py`, documentation): `git commit -am "preparing for releasing v${VERSION}`
* Create a tag: `git tag -as v${VERSION}` - use the release notes in the tag message.
* Make a clone: `git clone caldav/ caldav-release ; cd caldav-release ; git checkout v${VERSION}`
* Run tests (particularly the style check): `pytest` and `tox -e style`.
* Double-verify that the version-number in `__init__.py` is correct: `grep version caldav/__init__.py`
* Push the code to github: `cd ~/caldav ; git push ; git push --tags`
* Some people relies on the github release system for finding releases - go to https://github.com/python-caldav/caldav/releases/new, choose the new tag, copy the version number and the release notes in.
* The most important part - push to pypi: `cd ~/caldav-release ; python setup.py sdist bdist_wheel ; python -m twine upload dist/*`
* The most important part - push to pypi:
```
cd ~/caldav-release
python3 -m venv venv
. venv/bin/activate
pip install -U pip build twine
python -m build
python -m twine upload dist/*
```
3 changes: 1 addition & 2 deletions caldav/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import vobject.icalendar

__version__ = "1.3.9"

from ._version import __version__
from .davclient import DAVClient
from .objects import *

Expand Down
8 changes: 6 additions & 2 deletions caldav/davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from urllib.parse import unquote

import requests
import typing_extensions
from caldav.elements import dav
from caldav.lib import error
from caldav.lib.python_utilities import to_normal_str
Expand All @@ -35,6 +34,11 @@
else:
from collections.abc import Iterable, Mapping

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self


class DAVResponse:
"""
Expand Down Expand Up @@ -434,7 +438,7 @@ def __init__(

self._principal = None

def __enter__(self) -> typing_extensions.Self:
def __enter__(self) -> Self:
return self

def __exit__(
Expand Down
8 changes: 6 additions & 2 deletions caldav/elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
from caldav.lib.python_utilities import to_unicode
from lxml import etree
from lxml.etree import _Element
from typing_extensions import Self
from typing_extensions import TypeAlias


if sys.version_info < (3, 9):
from typing import Iterable
else:
from collections.abc import Iterable

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self


class BaseElement:
children: Optional[List[Self]] = None
Expand Down
7 changes: 6 additions & 1 deletion caldav/lib/url.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import typing
import urllib.parse
from typing import Union
Expand All @@ -12,7 +13,11 @@

from caldav.lib.python_utilities import to_normal_str
from caldav.lib.python_utilities import to_unicode
from typing_extensions import Self

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self


class URL:
Expand Down
9 changes: 7 additions & 2 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class hierarchy into a separate file)
from dateutil.rrule import rrulestr
from lxml import etree
from lxml.etree import _Element
from typing_extensions import Literal
from typing_extensions import Self
from vobject.base import VBase

from .elements.base import BaseElement
Expand Down Expand Up @@ -66,13 +64,20 @@ class hierarchy into a separate file)
from typing import Callable, Container, Iterator, Sequence
from typing import Iterable
from typing_extensions import DefaultDict
from typing_extensions import Literal
else:
from collections.abc import Callable
from collections.abc import Container
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from collections import defaultdict as DefaultDict
from typing import Literal

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self

_CC = TypeVar("_CC", bound="CalendarObjectResource")
log = logging.getLogger("caldav")
Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm[toml]>=7.0"]
build-backend = "setuptools.build_meta"

[project]
name = "caldav"
authors = [{ name = "Cyril Robert", email = "cyril@hippie.io" }]
license = { text = "GPL" }
description = "CalDAV (RFC4791) client library"
keywords = []
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Office/Business :: Scheduling",
"Topic :: Software Development :: Libraries :: Python Modules",
]
urls = { Homepage = "https://github.com/python-caldav/caldav" }
dependencies = [
"vobject",
"lxml",
"requests",
"icalendar",
"recurring-ical-events>=2.0.0",
"typing_extensions;python_version<'3.11'",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
"pytest-coverage",
"coverage",
"sphinx",
"backports.zoneinfo;python_version<'3.9'",
"tzlocal",
"xandikos==0.2.8;python_version<'3.9'",
"dulwich==0.20.50;python_version<'3.9'",
"xandikos;python_version>='3.9'",
]

[tool.setuptools_scm]
write_to = "caldav/_version.py"

[tool.setuptools]
py-modules = ["caldav"]
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["tests"]
namespaces = false
80 changes: 3 additions & 77 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,78 +1,4 @@
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import ast
import re
import sys
# -*- coding: utf-8 -*-
import setuptools

from setuptools import find_packages
from setuptools import setup

## I believe it's good practice to keep the version number
## available as package.__version__

## It is defitively good practice not to have to maintain the
## version number several places.

# However, there seems to be no "best current practice" on how
## to set up version number in the setup.py file?

## I've copied the following from the icalendar library:
_version_re = re.compile(r"__version__\s+=\s+(.*)")
with open("caldav/__init__.py", "rb") as f:
version = str(
ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1))
)

if __name__ == "__main__":
## TODO: consider if automated testing with radicale in addition to
## xandikos would yield any benefits.
test_packages = [
"pytest",
"pytest-coverage",
"coverage",
"sphinx",
"backports.zoneinfo;python_version<'3.9'",
"tzlocal",
"xandikos==0.2.8;python_version<'3.9'",
"dulwich==0.20.50;python_version<'3.9'",
"xandikos;python_version>='3.9'",
]

setup(
name="caldav",
version=version,
py_modules=[
"caldav",
],
description="CalDAV (RFC4791) client library",
long_description=open("README.md").read(),
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General " "Public License (GPL)",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Office/Business :: Scheduling",
"Topic :: Software Development :: Libraries " ":: Python Modules",
],
keywords="",
author="Cyril Robert",
author_email="cyril@hippie.io",
url="https://github.com/python-caldav/caldav",
license="GPL",
packages=find_packages(exclude=["tests"]),
include_package_data=True,
zip_safe=False,
install_requires=[
"vobject",
"lxml",
"requests",
"icalendar",
"recurring-ical-events>=2.0.0",
"typing_extensions",
],
extras_require={
"test": test_packages,
},
)
setuptools.setup()
File renamed without changes.
Loading