diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index f0072a1..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[bumpversion] -current_version = 0.0.9 -commit = True -tag = True - -[bumpversion:file:pyproject.toml] -search = version = "{current_version}" -replace = version = "{new_version}" - -[bumpversion:file:multiaddr/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9a243c7..10acf35 100644 --- a/.gitignore +++ b/.gitignore @@ -58,9 +58,6 @@ coverage.xml # Sphinx documentation docs/_build/ -# File just for checking my RST syntax -readme.html - # PyBuilder target/ diff --git a/HISTORY.rst b/HISTORY.rst index e47318c..b369f3e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,8 @@ History ======= +.. towncrier release notes start + 0.0.7 (2019-5-8) ---------------- diff --git a/Makefile b/Makefile index e17ff82..1285f25 100644 --- a/Makefile +++ b/Makefile @@ -11,20 +11,6 @@ endef export BROWSER_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" -help: - @echo "clean - remove all build, test, coverage and Python artifacts" - @echo "clean-build - remove build artifacts" - @echo "clean-pyc - remove Python file artifacts" - @echo "clean-test - remove test and coverage artifacts" - @echo "lint - check style with ruff" - @echo "test - run tests quickly with the default Python" - @echo "test-all - run tests on every Python version with tox" - @echo "coverage - check code coverage quickly with the default Python" - @echo "docs - generate Sphinx HTML documentation, including API docs" - @echo "release - package and upload a release" - @echo "dist - package" - @echo "install - install the package to the active Python's site-packages" - clean: clean-build clean-pyc clean-test clean-build: @@ -81,24 +67,41 @@ docs: servedocs: docs watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . -readme.html: README.rst - rst2html.py README.rst > readme.html - .PHONY: authors authors: git shortlog --numbered --summary --email | cut -f 2 > AUTHORS dist: clean - python setup.py sdist - python setup.py bdist_wheel + python -m build + ls -l dist install: clean python setup.py install -bump: - bumpversion --tag-name "{new_version}" patch - -deploy-prep: clean authors readme.html docs dist +# build newsfragments into release notes and verify docs build correctly +notes: check-bump validate-newsfragments + # Let UPCOMING_VERSION be the version that is used for the current bump + $(eval UPCOMING_VERSION=$(shell bump-my-version bump --dry-run $(bump) -v | awk -F"'" '/New version will be / {print $$2}')) + # Now generate the release notes to have them included in the release commit + towncrier build --yes --version $(UPCOMING_VERSION) + # Before we bump the version, make sure that the towncrier-generated docs will build + make docs + git commit -m "Compile release notes for v$(UPCOMING_VERSION)" + +deploy-prep: clean authors docs dist @echo "Did you remember to bump the version?" @echo "If not, run 'bumpversion {patch, minor, major}' and run this target again" @echo "Don't forget to update HISTORY.rst" + +# helpers + +# verify that newsfragments are valid and towncrier can build them +validate-newsfragments: + python ./newsfragments/validate_files.py + towncrier build --draft --version preview + +# verify that a bump argument is set to be passed to bump-my-version +check-bump: +ifndef bump + $(error bump must be set, typically: major, minor, patch, or devnum) +endif diff --git a/docs/multiaddr.rst b/docs/multiaddr.rst index fbe6033..3c57af5 100644 --- a/docs/multiaddr.rst +++ b/docs/multiaddr.rst @@ -5,9 +5,10 @@ Subpackages ----------- .. toctree:: + :maxdepth: 4 - multiaddr.codecs - multiaddr.resolvers + multiaddr.codecs + multiaddr.resolvers Submodules ---------- @@ -16,39 +17,38 @@ multiaddr.exceptions module --------------------------- .. automodule:: multiaddr.exceptions - :members: - :undoc-members: - :show-inheritance: + :members: + :show-inheritance: + :undoc-members: multiaddr.multiaddr module -------------------------- .. automodule:: multiaddr.multiaddr - :members: - :undoc-members: - :show-inheritance: + :members: + :show-inheritance: + :undoc-members: multiaddr.protocols module -------------------------- .. automodule:: multiaddr.protocols - :members: - :undoc-members: - :show-inheritance: + :members: + :show-inheritance: + :undoc-members: multiaddr.transforms module --------------------------- .. automodule:: multiaddr.transforms - :members: - :undoc-members: - :show-inheritance: - + :members: + :show-inheritance: + :undoc-members: Module contents --------------- .. automodule:: multiaddr - :members: - :undoc-members: - :show-inheritance: + :members: + :show-inheritance: + :undoc-members: diff --git a/multiaddr/multiaddr.py b/multiaddr/multiaddr.py index 2b4d81c..5ebc5d4 100644 --- a/multiaddr/multiaddr.py +++ b/multiaddr/multiaddr.py @@ -1,4 +1,3 @@ -# flake8: noqa: F811 import collections.abc from collections.abc import Iterator, Sequence from typing import Any, Optional, TypeVar, Union, overload diff --git a/newsfragments/65.feature.rst b/newsfragments/65.feature.rst new file mode 100644 index 0000000..fc767d4 --- /dev/null +++ b/newsfragments/65.feature.rst @@ -0,0 +1 @@ +Added support for CIDv1 format and improved sequence protocol handling with enhanced indexing and slicing operations. diff --git a/newsfragments/65.internal.rst b/newsfragments/65.internal.rst new file mode 100644 index 0000000..8a662b9 --- /dev/null +++ b/newsfragments/65.internal.rst @@ -0,0 +1 @@ +Enhanced type safety with comprehensive type hints, improved validation, and expanded test coverage for better code reliability and maintainability. diff --git a/newsfragments/68.feature.rst b/newsfragments/68.feature.rst new file mode 100644 index 0000000..dac4669 --- /dev/null +++ b/newsfragments/68.feature.rst @@ -0,0 +1 @@ +Adds DNSADDR protocol support. diff --git a/newsfragments/74.feature.rst b/newsfragments/74.feature.rst new file mode 100644 index 0000000..262ddb9 --- /dev/null +++ b/newsfragments/74.feature.rst @@ -0,0 +1 @@ +Adds support for p2p-circuit addresses. diff --git a/newsfragments/75.docs.rst b/newsfragments/75.docs.rst new file mode 100644 index 0000000..91438d3 --- /dev/null +++ b/newsfragments/75.docs.rst @@ -0,0 +1 @@ +Adds example of DNS address resolution. diff --git a/newsfragments/README.md b/newsfragments/README.md new file mode 100644 index 0000000..177d649 --- /dev/null +++ b/newsfragments/README.md @@ -0,0 +1,29 @@ +This directory collects "newsfragments": short files that each contain +a snippet of ReST-formatted text that will be added to the next +release notes. This should be a description of aspects of the change +(if any) that are relevant to users. (This contrasts with the +commit message and PR description, which are a description of the change as +relevant to people working on the code itself.) + +Each file should be named like `..rst`, where +`` is an issue number, and `` is one of: + +- `breaking` +- `bugfix` +- `deprecation` +- `docs` +- `feature` +- `internal` +- `misc` +- `performance` +- `removal` + +So for example: `123.feature.rst`, `456.bugfix.rst` + +If the PR fixes an issue, use that number here. If there is no issue, +then open up the PR first and use the PR number for the newsfragment. + +Note that the `towncrier` tool will automatically +reflow your text, so don't try to do any fancy formatting. Run +`towncrier build --draft` to get a preview of what the release notes entry +will look like in the final release notes. diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py new file mode 100755 index 0000000..ca7fa13 --- /dev/null +++ b/newsfragments/validate_files.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# Towncrier silently ignores files that do not match the expected ending. +# We use this script to ensure we catch these as errors in CI. + +import pathlib +import sys + +ALLOWED_EXTENSIONS = { + ".breaking.rst", + ".bugfix.rst", + ".deprecation.rst", + ".docs.rst", + ".feature.rst", + ".internal.rst", + ".misc.rst", + ".performance.rst", + ".removal.rst", +} + +ALLOWED_FILES = { + "validate_files.py", + "README.md", +} + +THIS_DIR = pathlib.Path(__file__).parent + +num_args = len(sys.argv) - 1 +assert num_args in {0, 1} +if num_args == 1: + assert sys.argv[1] in ("is-empty",) + +for fragment_file in THIS_DIR.iterdir(): + if fragment_file.name in ALLOWED_FILES: + continue + elif num_args == 0: + full_extension = "".join(fragment_file.suffixes) + if full_extension not in ALLOWED_EXTENSIONS: + raise Exception(f"Unexpected file: {fragment_file}") + elif sys.argv[1] == "is-empty": + raise Exception(f"Unexpected file: {fragment_file}") + else: + raise RuntimeError(f"Strange: arguments {sys.argv} were validated, but not found") diff --git a/pyproject.toml b/pyproject.toml index 5e2bfad..e4647b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,15 +24,15 @@ classifiers = [ ] requires-python = ">=3.9, <4.0" dependencies = [ - "varint", "base58", - "netaddr", + "dnspython>=2.7.0", "idna", + "netaddr", "py-cid", "py-multicodec >= 0.2.0", - "aiodns>=3.0.0", - "trio>=0.26.0", "trio-typing>=0.0.4", + "trio>=0.26.0", + "varint", ] [project.urls] @@ -41,23 +41,21 @@ Download = "https://github.com/multiformats/py-multiaddr/tarball/0.0.9" [project.optional-dependencies] dev = [ - "bumpversion==0.5.3", - "wheel>=0.31.0", - "watchdog>=3.0.0", - "tox==3.6.1", - "coverage==4.5.2", - "Sphinx==1.3.6", + "Sphinx>=5.0.0", + "build>=0.9.0", + "bump_my_version>=1.2.0", + "coverage>=6.5.0", + "pre-commit", + "pyright", "pytest", "pytest-cov", "pytest-runner", - "ruff", - "pyright", - "pre-commit", -] -test = [ - "pytest>=7.0.0", "pytest-trio>=0.5.2", - "pytest-cov>=4.0.0", + "ruff", + "towncrier>=24,<25", + "tox>=4.10.0", + "watchdog>=3.0.0", + "wheel>=0.31.0", ] [tool.setuptools] @@ -67,3 +65,110 @@ zip-safe = false [tool.pytest.ini_options] testpaths = ["tests"] + +[tool.towncrier] +# Read https://github.com/multiformats/py-multiaddr/blob/master/newsfragments/README.md for instructions +directory = "newsfragments" +filename = "HISTORY.rst" +issue_format = "`#{issue} `__" +package = "multiaddr" +title_format = "py-multiaddr v{version} ({project_date})" +underlines = ["-", "~", "^"] + +[[tool.towncrier.type]] +directory = "breaking" +name = "Breaking Changes" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bugfixes" +showcontent = true + +[[tool.towncrier.type]] +directory = "deprecation" +name = "Deprecations" +showcontent = true + +[[tool.towncrier.type]] +directory = "docs" +name = "Improved Documentation" +showcontent = true + +[[tool.towncrier.type]] +directory = "feature" +name = "Features" +showcontent = true + +[[tool.towncrier.type]] +directory = "internal" +name = "Internal Changes - for py-libp2p Contributors" +showcontent = true + +[[tool.towncrier.type]] +directory = "misc" +name = "Miscellaneous Changes" +showcontent = false + +[[tool.towncrier.type]] +directory = "performance" +name = "Performance Improvements" +showcontent = true + +[[tool.towncrier.type]] +directory = "removal" +name = "Removals" +showcontent = true + +[tool.bumpversion] +current_version = "0.0.9" +parse = """ + (?P\\d+) + \\.(?P\\d+) + \\.(?P\\d+) + (- + (?P[^.]*) + \\.(?P\\d+) + )? +""" +serialize = [ + "{major}.{minor}.{patch}-{stage}.{devnum}", + "{major}.{minor}.{patch}", +] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +tag = true +sign_tags = true +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" +allow_dirty = false +commit = true +message = "Bump version: {current_version} → {new_version}" + +[tool.bumpversion.parts.stage] +optional_value = "stable" +first_value = "stable" +values = [ + "alpha", + "beta", + "stable", +] + +[tool.bumpversion.part.devnum] + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = "version = \"{current_version}\"" +replace = "version = \"{new_version}\"" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = "current_version = \"{current_version}\"" +replace = "current_version = \"{new_version}\"" + +[[tool.bumpversion.files]] +filename = "multiaddr/__init__.py" +search = "__version__ = \"{current_version}\"" +replace = "__version__ = \"{new_version}\""