Skip to content

Commit

Permalink
Merge 67feb93 into bf22524
Browse files Browse the repository at this point in the history
  • Loading branch information
icgood committed Apr 1, 2023
2 parents bf22524 + 67feb93 commit 0eeb05e
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 89 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
python -m pip install --upgrade pip setuptools wheel invoke coveralls
python -m pip install --upgrade pip invoke coveralls
- name: Install package and dependencies
run: |
invoke install
Expand All @@ -47,9 +47,9 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
- name: Install build tools
run: |
python -m pip install --upgrade pip setuptools wheel invoke
python -m pip install --upgrade pip invoke
- name: Build the Sphinx documentation
run: |
invoke install doc.install doc.build
6 changes: 3 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip setuptools wheel twine
python -m pip install --upgrade pip build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
docs:
Expand All @@ -38,7 +38,7 @@ jobs:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip setuptools wheel invoke
python -m pip install --upgrade pip invoke
- name: Build the Sphinx documentation
run: |
invoke install doc.install doc.build
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

21 changes: 17 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import pkg_resources
from importlib.metadata import distribution

import cloud_sptheme as csp

Expand All @@ -26,7 +26,7 @@
author = 'Ian Good'

# The short X.Y version
project_version = pkg_resources.require(project)[0].version
project_version = distribution(project).version
version_parts = project_version.split('.')
version = '.'.join(version_parts[0:2])
# The full version, including alpha/beta/rc tags
Expand All @@ -44,7 +44,7 @@
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.githubpages',
'sphinx_autodoc_typehints',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -68,11 +68,24 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
if csp.is_cloud_theme(html_theme):
html_theme_options = {
'borderless_decor': True,
'sidebarwidth': '3in',
'hyphenation_language': 'en',
}


# -- Extension configuration -------------------------------------------------

autodoc_member_order = 'bysource'
autodoc_default_options = {'members': True, 'show-inheritance': True}
autodoc_default_flags = ['show-inheritance']
autodoc_typehints = 'description'
autodoc_typehints_format = 'short'

napoleon_numpy_docstring = False

Expand Down
60 changes: 59 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# Copyright (c) 2023 Ian C. Good
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

[build-system]
requires = ['setuptools', 'wheel']
requires = ['hatchling']
build-backend = 'hatchling.build'

[project]
name = 'swim-protocol'
version = '0.3.11'
authors = [
{ name = 'Ian Good', email = 'ian@icgood.net' },
]
description = 'SWIM protocol implementation for exchanging cluster membership status and metadata.'
license = { file = 'LICENSE.md' }
readme = { file = 'README.md', content-type = 'text/markdown' }
requires-python = '~=3.9'
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]

[project.optional-dependencies]
crc32c = ['crc32c ~= 2.2']

[project.urls]
homepage = 'https://github.com/icgood/swim-protocol/'

[project.scripts]
swim-protocol-demo = 'swimprotocol.demo:main'

[project.entry-points.'swimprotocol.transport']
udp = 'swimprotocol.udp:UdpTransport'

[tool.hatch.build]
exclude = ['/tasks', '/doc', '/.github']

[tool.mypy]
strict = true
Expand Down
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ pytest-cov
bandit[toml]
rope

types-setuptools

-e '.'
56 changes: 0 additions & 56 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions swimprotocol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

from __future__ import annotations

import pkg_resources
from importlib.metadata import distribution

__all__ = ['__version__']

#: The package version string.
#:
#: See Also:
#: `PEP 396 <https://www.python.org/dev/peps/pep-0396/>`_
__version__: str = pkg_resources.require('swim-protocol')[0].version
__version__: str = distribution('swim-protocol').version
20 changes: 6 additions & 14 deletions swimprotocol/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from abc import abstractmethod, ABCMeta
from contextlib import AbstractAsyncContextManager
from typing import Generic, TypeVar, Final, ClassVar, Optional
from importlib.metadata import entry_points
from typing import Generic, TypeVar, Final, ClassVar

from pkg_resources import iter_entry_points, DistributionNotFound

from .config import ConfigT_co, BaseConfig
from .members import Members
Expand All @@ -31,18 +31,10 @@ def load_transport(name: str = 'udp', *, group: str = __name__) \
KeyError: The given name did not exist in the entry point group.
"""
last_exc: Optional[DistributionNotFound] = None
for entry_point in iter_entry_points(group, name):
try:
transport_type: type[Transport[BaseConfig]] = entry_point.load()
except DistributionNotFound as exc:
last_exc = exc
else:
return transport_type
if last_exc is not None:
raise last_exc
else:
raise KeyError(f'{name!r} entry point not found in {group!r}')
for entry_point in entry_points(group=group, name=name):
transport_type: type[Transport[BaseConfig]] = entry_point.load()
return transport_type
raise KeyError(f'{name!r} entry point not found in {group!r}')


class Transport(Generic[ConfigT_co], metaclass=ABCMeta):
Expand Down
2 changes: 1 addition & 1 deletion tasks/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@task(check_import)
def flake8(ctx):
"""Run the flake8 linter."""
ctx.run('flake8 {} test {} *.py'.format(ctx.package, __package__))
ctx.run('flake8 {} test {}'.format(ctx.package, __package__))


@task(check_import)
Expand Down

0 comments on commit 0eeb05e

Please sign in to comment.