add code to replace the import commands to fix execution errors
This commit is contained in:
14
setup.py
14
setup.py
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -28,6 +29,18 @@ def generateProtobuf(source):
|
|||||||
if 0 != subprocess.call(command):
|
if 0 != subprocess.call(command):
|
||||||
sys.exit(-1)
|
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
|
# @brief Cleans up all auto-generated files and folders
|
||||||
# @param[in] _clean Instance of setuptools to clean up the system
|
# @param[in] _clean Instance of setuptools to clean up the system
|
||||||
class clean(_clean):
|
class clean(_clean):
|
||||||
@@ -76,6 +89,7 @@ setup(
|
|||||||
'configparser',
|
'configparser',
|
||||||
'protobuf',
|
'protobuf',
|
||||||
'pyzmq',
|
'pyzmq',
|
||||||
|
're',
|
||||||
'setuptools'
|
'setuptools'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user