##assert os.path.exists(os.path.join(executableDir, executableName)) not valid anymore with zipapp. But it worked for years, so I guess the code is ok.
argv[0]=os.path.join(executableDir,executableName)#NSM speciality. nsmclient exlicitely checks for this
#no support for system-wide cbox in compiled mode. Error handling at the bottom of the file
importzipfile
importtempfile
logger.info("Extracting shared library to temporary directory")
zipfilePath=get_script_dir().rstrip("/template")
assertzipfile.is_zipfile(zipfilePath),(zipfilePath)#in our tests this worked. but in lss this results not in a zip file header. linux file also says it is no zip. However, unzip works.
#Extract included .so to tmp dir, tmp dir gets garbage collected at the end of our program.
startSingleNSMServer(path)#provides NSM_URL environment variable and a limited drop-in replacement for NSM that will only answer to our application
assertgetenv("NSM_URL")
sys.path.append("site-packages")# If you compiled but did not install you can still run with the local build of cbox in our temp dir site-packages. Add path to the last place, in case there is an installed or bundled version
sys.path.append("sitepackages")# If you compiled but did not install you can still run with the local build of cbox in our temp dir sitepackages. Add path to the last place, in case there is an installed or bundled version
ifargs.directory:
#Switch to the mode without NSM.
@ -344,20 +360,24 @@ if "CALFBOXLIBABSPATH" in os.environ:
else:
logger.info("Looking for calfbox shared library systemwide through ctypes.util.find_library")
try:
fromcalfboximportcbox
logger.info("{}: using cbox python module from {} . Local version has higher priority than system wide.".format(METADATA["name"],os.path.abspath(cbox.__file__)))
exceptExceptionase:
print(e)
print("Here is some information. Please show this to the developers.")
logger.info("{}: using cbox python module from {} . Local version has higher priority than system wide.".format(METADATA["name"],os.path.abspath(cbox.__file__)))
exceptExceptionase:
print(e)
print("Here is some information. Please show this to the developers.")