yioda / ansible-inventory-to-ssh-config

This is a python tool for updating ssh config from ansible inventory file.
MIT License
25 stars 6 forks source link

Use of `pkg_resources` is deprecated in favor of importlib.resources #11

Closed yioda closed 1 month ago

yioda commented 1 month ago

Since the pkg_resources would be deprecated in setuptools, I should refactor the version showing option with [importlib.resources](https://docs.python.org/3.11/library/importlib.resources.html#module-importlib.resources).

REF: https://setuptools.pypa.io/en/latest/pkg_resources.html

Current workaround is commenting as following:

 from ansible.inventory.manager import InventoryManager
 from ansible.parsing.dataloader import DataLoader
 from ansible.vars.manager import VariableManager
-from pkg_resources import get_distribution
 from sshconf import empty_ssh_config_file, read_ssh_config_file

 def get_args():
     parser = ArgumentParser(formatter_class=RawTextHelpFormatter)
-    parser.add_argument('-v', '--version', action='version',
-                        version=get_distribution('ansible-inventory-to-ssh-config').version)
     parser.add_argument("inventory_file", help="ansible inventory file")
     parser.add_argument("-o", "--output",
                         help="ssh config output path (default: ~/.ssh/config.ansible)",

I will fix this as soon as possible...

yioda commented 1 month ago

Fix in new version 1.1.2

Use importlib.metadata to replace the pkg_resource.

https://github.com/yioda/ansible-inventory-to-ssh-config/releases/tag/1.1.2