Skip to content

Commit

Permalink
Add pyproject.toml
Browse files Browse the repository at this point in the history
This also has the side effect of messing up my __main__; because
setuptools doesn't support __main__ modules, the entrypoints must refer
to a function.

Reference: pypa/setuptools#1995
  • Loading branch information
olof committed Mar 12, 2023
1 parent 42e6e30 commit b8ae3b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mxmda/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
from mxmda.app import command, parse_args
from mxmda.errors import UserError

if __name__ == '__main__':
# https://github.com/pypa/setuptools/issues/1995
# Proper solution specified in comment by @Xophmeister:
# > In the current system, you have to delimit module and the
# > entrypoint callable with a colon. What if the logic was
# > something like:
# >
# > Split on:
# > If there are two components, then proceed as currently;
# > If there is only one component, then interpret this as
# > a direct module invocation?
def issue_1995():
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)-8s] %(name)s: %(message)s',
Expand All @@ -18,3 +28,6 @@
except UserError as exc:
logging.getLogger(mxmda.__name__).error(exc)
sys.exit(1)

if __name__ == '__main__':
issue_1995()
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "mxmda"
version = "0.1.0"
description = "Matrix Mail Delivery Agent"

authors = [
{ name="Olof Johansson", email="olof@ethup.se" },
]

readme = "README"
requires-python = ">=3.6"

dependencies = [
"matrix-nio[e2e]",
"PyYAML",
"requests",
]

[project.scripts]
mxmda = "mxmda.__main__:issue_1995"

[project.urls]
"Homepage" = "https://github.com/olof/mxmda"
"Bug Tracker" = "https://github.com/olof/mxmda/issues"

[tool.setuptools]
packages = ["mxmda"]

0 comments on commit b8ae3b8

Please sign in to comment.