From 1d50f0e9aff241b2fb87a8b1846b1b7c90de348a Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 19 Aug 2021 09:18:54 +0200 Subject: [PATCH] add code to replace the import commands to fix execution errors --- setup.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setup.py b/setup.py index 67ef4a9..6fef9bb 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import re import shutil import subprocess import sys @@ -28,6 +29,18 @@ def generateProtobuf(source): if 0 != subprocess.call(command): sys.exit(-1) + # check if we need to replace some import commands + replaced = False + content = open(output, 'r').read() + for entry in re.findall('import.[A-Z].*.as.*', content): + content = content.replace(entry, 'from . ' + entry) + replaced = True + + # update the content + if replaced: + with open(output, 'w') as file: + file.write(content) + # @brief Cleans up all auto-generated files and folders # @param[in] _clean Instance of setuptools to clean up the system class clean(_clean): @@ -76,6 +89,7 @@ setup( 'configparser', 'protobuf', 'pyzmq', + 're', 'setuptools' ] )