Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace pkg_resources for python 3.12 #480

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions agents/fake/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
author='Roman Zeyde',
author_email='dev@romanzey.de',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
scripts=['fake_device_agent.py'],
install_requires=[
'libagent>=0.9.0',
Expand Down
1 change: 1 addition & 0 deletions agents/jade/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='Jamie C. Driver',
author_email='jamie@blockstream.com',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
scripts=['jade_agent.py'],
install_requires=[
'libagent>=0.14.5',
Expand Down
1 change: 1 addition & 0 deletions agents/keepkey/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='Roman Zeyde',
author_email='dev@romanzey.de',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
scripts=['keepkey_agent.py'],
install_requires=[
'libagent>=0.9.0',
Expand Down
1 change: 1 addition & 0 deletions agents/ledger/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='Roman Zeyde',
author_email='dev@romanzey.de',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
scripts=['ledger_agent.py'],
install_requires=[
'libagent>=0.9.0',
Expand Down
1 change: 1 addition & 0 deletions agents/onlykey/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='CryptoTrust',
author_email='t@crp.to',
url='http://github.com/trustcrypto/onlykey-agent',
python_requires='>=3.8',
scripts=['onlykey_agent.py'],
install_requires=[
'libagent>=0.14.2',
Expand Down
1 change: 1 addition & 0 deletions agents/trezor/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='Roman Zeyde',
author_email='dev@romanzey.de',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
scripts=['trezor_agent.py'],
install_requires=[
'libagent>=0.14.0',
Expand Down
7 changes: 3 additions & 4 deletions libagent/age/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import logging
import os
import sys
from importlib import metadata

import bech32
import pkg_resources
from cryptography.exceptions import InvalidTag
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305

Expand Down Expand Up @@ -150,9 +150,8 @@ def main(device_type):
p = argparse.ArgumentParser()

agent_package = device_type.package_name()
resources_map = {r.key: r for r in pkg_resources.require(agent_package)}
resources = [resources_map[agent_package], resources_map['libagent']]
versions = '\n'.join('{}={}'.format(r.key, r.version) for r in resources)
resources = [metadata.distribution(agent_package), metadata.distribution('libagent')]
versions = '\n'.join('{}={}'.format(r.metadata['Name'], r.version) for r in resources)
p.add_argument('--version', help='print the version info',
action='version', version=versions)

Expand Down
7 changes: 3 additions & 4 deletions libagent/gpg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import stat
import subprocess
import sys
from importlib import metadata

try:
# TODO: Not supported on Windows. Use daemoniker instead?
import daemon
except ImportError:
daemon = None
import pkg_resources
import semver

from .. import device, formats, server, util
Expand Down Expand Up @@ -308,9 +308,8 @@ def main(device_type):
parser = argparse.ArgumentParser(epilog=epilog)

agent_package = device_type.package_name()
resources_map = {r.key: r for r in pkg_resources.require(agent_package)}
resources = [resources_map[agent_package], resources_map['libagent']]
versions = '\n'.join('{}={}'.format(r.key, r.version) for r in resources)
resources = [metadata.distribution(agent_package), metadata.distribution('libagent')]
versions = '\n'.join('{}={}'.format(r.metadata['Name'], r.version) for r in resources)
parser.add_argument('--version', help='print the version info',
action='version', version=versions)

Expand Down
7 changes: 3 additions & 4 deletions libagent/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import tempfile
import threading
from importlib import metadata

import configargparse

Expand All @@ -21,7 +22,6 @@
import daemon
except ImportError:
daemon = None
import pkg_resources

from .. import device, formats, server, util
from . import client, protocol
Expand Down Expand Up @@ -83,9 +83,8 @@ def create_agent_parser(device_type):
p.add_argument('-v', '--verbose', default=0, action='count')

agent_package = device_type.package_name()
resources_map = {r.key: r for r in pkg_resources.require(agent_package)}
resources = [resources_map[agent_package], resources_map['libagent']]
versions = '\n'.join('{}={}'.format(r.key, r.version) for r in resources)
resources = [metadata.distribution(agent_package), metadata.distribution('libagent')]
versions = '\n'.join('{}={}'.format(r.metadata['Name'], r.version) for r in resources)
p.add_argument('--version', help='print the version info',
action='version', version=versions)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author='Roman Zeyde',
author_email='dev@romanzey.de',
url='http://github.com/romanz/trezor-agent',
python_requires='>=3.8',
packages=[
'libagent',
'libagent.age',
Expand Down