| 1 | From: Branch Vincent (PR #178, twtxt repository)
|
| 2 | Date: Apr 21, 2024
|
| 3 | Subject: replace pkg_resources for python 3.12
|
| 4 |
|
| 5 | * Python 3.12 has removed bundled setuptools (aka pkg_resources):
|
| 6 | https://docs.python.org/3.12/whatsnew/3.12.html#removed
|
| 7 |
|
| 8 | |
| 9 | |
| 10 | @@ -14,7 +14,6 @@
|
| 11 | import textwrap
|
| 12 |
|
| 13 | import click
|
| 14 | -import pkg_resources
|
| 15 |
|
| 16 | from twtxt.mentions import format_mentions
|
| 17 | from twtxt.parser import parse_iso8601
|
| 18 | @@ -164,11 +163,7 @@
|
| 19 |
|
| 20 |
|
| 21 | def generate_user_agent():
|
| 22 | - try:
|
| 23 | - version = pkg_resources.require("twtxt")[0].version
|
| 24 | - except pkg_resources.DistributionNotFound:
|
| 25 | - version = "unknown"
|
| 26 | -
|
| 27 | + from twtxt import __version__ as version
|
| 28 | conf = click.get_current_context().obj["conf"]
|
| 29 | if conf.disclose_identity and conf.nick and conf.twturl:
|
| 30 | user_agent = "twtxt/{version} (+{url}; @{nick})".format(
|