Hi Gregory,
Thanks for your response. I did not try the setup.py approach. I will give it a try.
I did make some progress with my problem. I moved version.txt into the top-level package and used importlib.resources to refer to my version.txt and as you mentioned importlib.resources expect files to be inside a package
I also got FileManifest approach work for cases where the files cannot reside inside the package folder. Here is my make_exe function
def make_install(exe):
# Create an object that represents our installed application file layout.
files = FileManifest()
scripts = glob(["/home/testuser/workspace/terraform-mae/scripts/tfe.sh"], strip_prefix="/home/testuser/workspace/terraform-mae/")
templates = glob(["/home/testuser/workspace/terraform-mae/terraform_mae/templates/**/*"], strip_prefix="/home/testuser/workspace/terraform-mae/terraform_mae/")
# Add the generated executable to our install layout in the root directory.
files.add_python_resource(".", exe)
files.add_manifest(scripts)
files.add_manifest(templates))
return files
Pyoxidizer creates these directories relative to the directory where the executable exists. I added the path of the executable to sys.paths like below.
def make_exe(dist):
# This variable defines the configuration of the
# embedded Python interpreter.
python_config = PythonInterpreterConfig(
sys_paths=["$ORIGIN","$ORIGIN/lib"],
run_module="terraform_mae.mae"
)
And finally, I updated my python code like below to reference those files. Not sure if this is the cleanest approach, but for works for now.
scripts = os.path.join(sys.path[0], "scripts/tfe.sh")
The bad part with the FileManifest approach is I cannot provide a single executable to my customer, instead, I need to provide a zip file with all its dependencies.
Thanks
Sankar