Remove runtime dependency on pbr

Pbr is a very heavy package to depend on. It requires git-core, which is
16 MiB on my Fedora. We only use it to detect the version, which can be
done without pbr using a much lighter importlib_metadata.

Copied from https://review.opendev.org/c/openstack/osprofiler/+/739379

Change-Id: I5f434e6bfde6f645804941f3a36d5458a28270e7
This commit is contained in:
Dmitry Tantsur 2021-04-26 09:14:08 +02:00
parent 9edb13d891
commit 3251d7b641
4 changed files with 13 additions and 7 deletions

View File

@ -150,7 +150,7 @@ class APIClient(object):
data['agent_token'] = self.agent_token
if api_ver >= AGENT_VERSION_IRONIC_VERSION:
data['agent_version'] = version.version_info.release_string()
data['agent_version'] = version.__version__
if api_ver >= AGENT_VERIFY_CA_IRONIC_VERSION and generated_cert:
data['agent_verify_ca'] = generated_cert

View File

@ -148,7 +148,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
self.assertEqual(API_URL + heartbeat_path, request_args[1])
expected_data = {
'callback_url': 'http://192.0.2.1:9999',
'agent_version': version.version_info.release_string()}
'agent_version': version.__version__}
self.assertEqual(jsonutils.dumps(expected_data), data)
def test_successful_heartbeat_ip6(self):
@ -171,7 +171,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
self.assertEqual(API_URL + heartbeat_path, request_args[1])
expected_data = {
'callback_url': 'http://[fc00:1111::4]:9999',
'agent_version': version.version_info.release_string()}
'agent_version': version.__version__}
self.assertEqual(jsonutils.dumps(expected_data), data)
def test_successful_heartbeat_with_token(self):
@ -196,7 +196,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
expected_data = {
'callback_url': 'http://192.0.2.1:9999',
'agent_token': 'magical',
'agent_version': version.version_info.release_string()}
'agent_version': version.__version__}
self.assertEqual(jsonutils.dumps(expected_data), data)
def test_heartbeat_agent_version_unsupported(self):
@ -244,7 +244,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
expected_data = {
'callback_url': 'https://192.0.2.1:9999',
'agent_token': 'magical',
'agent_version': version.version_info.release_string(),
'agent_version': version.__version__,
'agent_verify_ca': 'I am a cert'}
self.assertEqual(jsonutils.dumps(expected_data), data)
headers = self.api_client.session.request.call_args[1]['headers']

View File

@ -13,6 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import pbr.version
try:
# For Python 3.8 and later
import importlib.metadata as importlib_metadata
except ImportError:
# For everyone else
import importlib_metadata
version_info = pbr.version.VersionInfo('ironic_python_agent')
__version__ = importlib_metadata.version("ironic_python_agent")

View File

@ -2,6 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
netifaces>=0.10.4 # MIT
oslo.config>=5.2.0 # Apache-2.0