Skip to content

Commit

Permalink
Merge pull request #707 from niccokunzmann/issue-686-pyproject.toml
Browse files Browse the repository at this point in the history
Use pyproject.toml
  • Loading branch information
niccokunzmann authored Sep 28, 2024
2 parents ca13228 + cc4635f commit ca260c8
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 111 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine setuptools
pip install build twine
- name: Build distribution files
run: python setup.py bdist_wheel sdist
run: python -m build # same as in deploy-tag-to-pypi
- name: Check distribution files
run: twine check dist/*

Expand Down Expand Up @@ -115,22 +115,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine setuptools
- name: Check the tag
run: |
PACKAGE_VERSION=`python setup.py --version`
TAG_NAME=v$PACKAGE_VERSION
echo "Package version $PACKAGE_VERSION with possible tag name $TAG_NAME on $GITHUB_REF_NAME"
# test that the tag represents the version
# see https://docs.github.com/en/actions/learn-github-actions/environment-variables
if [ "$TAG_NAME" != "$GITHUB_REF_NAME" ]; then
echo "ERROR: This tag is for the wrong version. Got \"$GITHUB_REF_NAME\" expected \"$TAG_NAME\"."
exit 1
fi
pip install build twine
- name: remove old files
run: rm -rf dist/*
- name: build distribution files
run: python setup.py bdist_wheel sdist
run: python -m build # same as in test-distribution
- name: deploy to pypi
run: |
# You will have to set the variables TWINE_USERNAME and TWINE_PASSWORD
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ src/icalendar.egg-info/
!.gitignore
venv
/ical_fuzzer.pkg.spec
/src/icalendar/_version.py

coverage.xml
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog

Minor changes:

- add ``__all__`` variable to each modules in ``icalendar`` package
- Add ``__all__`` variable to each modules in ``icalendar`` package
- Improve test coverage.
- Adapt ``test_with_doctest.py`` to correctly run on Windows.
- Measure branch coverage when running tests.
Expand All @@ -18,7 +18,7 @@ Breaking changes:

New features:

- ...
- Use ``pyproject.toml`` file instead of ``setup.py``

Bug fixes:

Expand Down
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,16 @@ Related projects
* `icalevents <https://github.com/irgangla/icalevents>`_. It is built on top of icalendar and allows you to query iCal files and get the events happening on specific dates. It manages recurrent events as well.
* `recurring-ical-events <https://pypi.org/project/recurring-ical-events/>`_. Library to query an ``ICalendar`` object for events happening at a certain date or within a certain time.
* `x-wr-timezone <https://pypi.org/project/x-wr-timezone/>`_. Library to make ``ICalendar`` objects and files using the non-standard ``X-WR-TIMEZONE`` compliant with the standard (RFC 5545).

Further Reading
===============

You can find out more about this project:

* `Contributing`_
* `Changelog`_
* `License`_

.. _`Contributing`: https://icalendar.readthedocs.io/en/latest/contributing.html
.. _`Changelog`: https://icalendar.readthedocs.io/en/latest/changelog.html
.. _`License`: https://icalendar.readthedocs.io/en/latest/license.html
10 changes: 10 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ This is how you can run ``tox`` with Python 3.9:
tox -e py39
Code Style
----------

We strive towards a common code style.
You can run the following command to auto-format the code.

.. code-block:: shell
tox -e ruff
Accessing a ``tox`` environment
-------------------------------

Expand Down
191 changes: 191 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#
# We use the pyproject.toml package specification.
# See https://packaging.python.org/en/latest/guides/section-build-and-publish/
# See https://github.com/collective/icalendar/issues/686
# See https://packaging.python.org/en/latest/specifications/pyproject-toml/
#

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "icalendar"
license = { file = "LICENSE.rst", name = "BSD-2-Clause" }
# name = "BSD-2-Clause", # TODO: is this the right short key
keywords = [
"calendar",
"calendaring",
"ical",
"icalendar",
"event",
"todo",
"journal",
"recurring",
"rfc5545",
]
# This email is not in use any more. If you find a better one, go ahead!
# See https://github.com/collective/icalendar/pull/707#discussion_r1775275335
authors = [
{ name="Plone Foundation", email="plone-developers@lists.sourceforge.net" },
]
maintainers = [
{ name="Nicco Kunzmann", email="niccokunzmann@rambler.ru" },
{ name="Christian Geier" },
{ name="Jaca", email="vitouejj@gmail.com" },
]
# These attributes are dynamically generated by hatch-vcs
dynamic = [
"urls",
"version"
]
description = "iCalendar parser/generator"
readme = { file = "README.rst", content-type = "text/x-rst" }

#
# When adjusting the Python Version, adjust also:
# - .github/workflows/tests.yml
# - the classifiers below
# - the documentation
# - the README file
# - dependencies for 3.8, Python 3.13 will come our October, too
# - tool.ruff.target-version
#
requires-python = ">=3.8"

# see https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]

dependencies = [
"python-dateutil",
# install requirements depending on python version, TODO: Remove with Python 3.8
# see https://www.python.org/dev/peps/pep-0508/#environment-markers
"backports.zoneinfo; python_version < '3.9'",
"tzdata"
]

[project.optional-dependencies]
test = [
"pytest",
"coverage",
"hypothesis",
"pytz",
]

[project.scripts]
icalendar = "icalendar.cli:main"

[tool.hatch.build]
exclude = [
"/.*",
"/*.*",
"/src/icalendar/fuzzing",
"/docs",
"/dist",
"/build",
"/htmlcov",
]

[tool.hatch.metadata.hooks.vcs.urls]
# This is a dynamic generation of [project.urls]
Homepage = "https://icalendar.readthedocs.io/"
Repository = "https://github.com/collective/icalendar/"
source_archive = "https://github.com/collective/icalendar/archive/{commit_hash}.zip"
Issues = "https://github.com/collective/icalendar/issues"
Documentation = "https://icalendar.readthedocs.io/"
Changelog = "https://icalendar.readthedocs.io/en/latest/changelog.html"

[tool.hatch.version]
# This configuration allows us to use the version from the tags and dynamically generate
# version files. This speeds up the release process.
source = "vcs"

[tool.hatch.version.raw-options]
# see https://github.com/ofek/hatch-vcs/issues/43#issuecomment-1553065222
local_scheme = "no-local-version"

[tool.hatch.build.hooks.vcs]
version-file = "src/icalendar/_version.py"

[tool.hatch.metadata]
allow-direct-references = true

[tool.ruff]
target-version = "py38"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN", # flake8-annotations
"B020", # Loop control variable {name} overrides iterable it iterates
"C401", # Unnecessary generator (rewrite as a set comprehension)
"C901", # {name} is too complex ({complexity} > {max_complexity})
"COM812", # Trailing comma missing
"D1", # Missing docstring
"D2", # docstrings stuffs
"D4", # docstrings stuffs
"EM10", # Exception string usage
"ERA001", # Found commented-out code
"FBT002", # Boolean default positional argument in function definition
"FIX", # TODO comments
"ISC001", # Implicitly concatenated string literals on one line (to avoid with formatter)
"N818", # Exception name {name} should be named with an Error suffix
"PLR091", # Too many things (complexity, arguments, branches, etc...)
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"RUF012", # Mutable class attributes should be annotated with typing.ClassVar
"RUF015", # Prefer next({iterable}) over single element slice
"S101", # Use of assert detected
"TD", # TODO comments
"TRY003", # Avoid specifying long messages outside the exception class
"S104", # Possible binding to all interfaces
"E722", # Do not use bare `except`
"RUF005", # Consider iterable unpacking instead of concatenation
"DTZ005", # `datetime.datetime.now()` called without a `tz` argument
"PERF401", # Use a list comprehension to create a transformed list
"ARG002", # Unused method argument: ...
"ARG001", # Unused function argument: ...
]
extend-safe-fixes = [
"PT006", # Wrong type passed to first argument of @pytest.mark.parametrize; expected {expected_string}
]

[tool.ruff.lint.per-file-ignores]
"src/icalendar/tests/*" = [
"B011", # Do not assert False (python -O removes these calls), raise AssertionError()
"DTZ001", # datetime.datetime() called without a tzinfo argument
"E501", # Indentation is not a multiple of {indent_size}
"N802", # Function name {name} should be lowercase
"PT011", # pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception
"PT012", # pytest.raises() block should contain a single simple statement
"PT015", # Assertion always fails, replace with pytest.fail()
"T201", # print found
"T203", # `pprint` found
"RUF001", # String contains ambiguous character
]

[tool.pytest.ini_options]
# see https://docs.pytest.org/en/6.2.x/customize.html
minversion = "6.0"
# see https://docs.pytest.org/en/6.2.x/reference.html?highlight=testpaths#confval-testpaths
testpaths = [
"src/icalendar/tests",
]
# see https://docs.pytest.org/en/6.2.x/reference.html?highlight=testpaths#confval-norecursedirs
norecursedirs = [
"src/icalendar/tests/hypothesis",
"build",
]

18 changes: 0 additions & 18 deletions setup.cfg

This file was deleted.

67 changes: 0 additions & 67 deletions setup.py

This file was deleted.

4 changes: 3 additions & 1 deletion src/icalendar/tests/test_create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ set -e
cd "`dirname \"$0\"`"
cd "../../.."

python3 setup.py sdist
rm -rf dist
pip3 install build
python3 -m build
archive=`echo dist/icalendar-*.tar.gz`

if ! [ -f "$archive" ]; then
Expand Down
13 changes: 13 additions & 0 deletions src/icalendar/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Version file as a stable interface for the generated _version.py file."""
try:
from ._version import __version__, __version_tuple__, version, version_tuple
except ModuleNotFoundError:
__version__ = version = "0.0.0dev0"
__version_tuple__ = version_tuple = (0, 0, 0, "dev0")

__all__ = [
"__version__",
"version",
"__version_tuple__",
"version_tuple",
]
Loading

0 comments on commit ca260c8

Please sign in to comment.