Skip to content

Commit

Permalink
Rely on importlib_metadata 3.6 for nicer protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 24, 2021
1 parent c1807fa commit ee63c58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog/732.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rely on importlib_metadata 3.6 for nicer entry point processing.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires=
requests-toolbelt >= 0.8.0, != 0.9.0
setuptools >= 0.7.0
tqdm >= 4.14
importlib_metadata; python_version < "3.8"
importlib_metadata >= 3.6
keyring >= 15.1
rfc3986 >= 1.4.0
colorama >= 0.4.3
Expand Down
17 changes: 5 additions & 12 deletions twine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from typing import Any, Dict, List, Tuple
from typing import Any, List, Tuple

import importlib_metadata
import pkginfo
import requests
import requests_toolbelt
Expand All @@ -22,19 +23,10 @@

import twine
from twine import _installed
from twine import importlib_metadata

args = argparse.Namespace()


def _registered_commands(
group: str = "twine.registered_commands",
) -> Dict[str, importlib_metadata.EntryPoint]:
# todo: with python/importlib_metadata#278:
# return importlib_metadata.entry_points()[group]
return {ep.name: ep for ep in importlib_metadata.entry_points()[group]}


def list_dependencies_and_versions() -> List[Tuple[str, str]]:
return [
("pkginfo", _installed.Installed(pkginfo).version),
Expand All @@ -52,7 +44,8 @@ def dep_versions() -> str:


def dispatch(argv: List[str]) -> Any:
registered_commands = _registered_commands()
registered_commands = importlib_metadata.entry_points(
group='twine.registered_commands')
parser = argparse.ArgumentParser(prog="twine")
parser.add_argument(
"--version",
Expand All @@ -68,7 +61,7 @@ def dispatch(argv: List[str]) -> Any:
)
parser.add_argument(
"command",
choices=registered_commands.keys(),
choices=registered_commands.names,
)
parser.add_argument(
"args",
Expand Down

0 comments on commit ee63c58

Please sign in to comment.