From 2127bc9db46f7ae0cb69392c4fb1f325d96aad50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Corn=C3=A9=20Lukken?= <lukken@astron.nl>
Date: Wed, 5 Apr 2023 09:18:27 +0000
Subject: [PATCH] Use correct native importlib library available Python 3.7+

---
 .gitlab-ci.yml   | 13 ++++++++++++-
 pypcc/pypcc.py   | 10 +++++-----
 requirements.txt |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d46497d..b7b2db1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,16 @@
-stages: 
+stages:
+  - run
   - image
+
+test-run:
+  stage: run
+  image: python:3.11
+  before_script:
+    - pip3 install -r requirements.txt
+    - python3 setup.py install
+  script:
+    - hwtr -h
+
 docker-build:
   stage: image
   image: docker:latest
diff --git a/pypcc/pypcc.py b/pypcc/pypcc.py
index af1cb03..1e121ca 100755
--- a/pypcc/pypcc.py
+++ b/pypcc/pypcc.py
@@ -1,10 +1,10 @@
-import logging
+from importlib import metadata
 import argparse
+import logging
+import signal
+import sys
 import threading
 import time
-import sys
-import signal
-from importlib_metadata import metadata
 
 parser = argparse.ArgumentParser()
 parser.add_argument("-s", "--simulator", help="Do not connect to I2c, but simulate behaviour.", action="store_true")
@@ -26,7 +26,7 @@ args = parser.parse_args()
 #}
 #configure_logger(logstash_host=args.loghost,level=args.loglevel, log_extra=log_extra)
 logging.getLogger().setLevel(args.loglevel)
-git_hash=metadata("pypcc")["Summary"]
+git_hash=metadata.metadata("pypcc")["Summary"]
 logging.info("Git Hash="+git_hash)
 
 from pypcc.opcuaserv import opcuaserv
diff --git a/requirements.txt b/requirements.txt
index 7d582b2..eb6844a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-git+https://github.com/amaork/libi2c.git; platform_system == "linux"
+git+https://github.com/amaork/libi2c.git; platform_system == "Linux"
 asyncua
 numpy
 recordclass
-- 
GitLab