Can cx_Freeze keep a selected import outside of library.zip?

20 views Asked by At

I have a Python program that reads in some parameters from an external my_parameters.py file. This external file simply assigns some variables to values, for example:

# My parameter file
param1 = 3
param2 = 4

I am loading this file into the main python program with

import my_parameters as mP

# do stuff with ( mP.param1 )  etc...

This works as expected. Now I want to package my python program as a standalone .exe file so that the user will not have to separately install all the necessary python libraries. For this I am using cx_Freeze. After invoking the setup.py build process, I get a build directory with my program.exe file and a library containing a very large number of DLL packages, and the .exe does in fact work as expected.

The only problem is that the my_parameters.py file that I wanted to be a plain text file that the user can directly edit, has been moved inside the lib/library.zip file, and has also been converted to a compiled format my_parameters.pyc

Is there some easy way to get a .exe version of my python program, and yet still be able to load in an external plain-text file like my_parameter.py for easy user configuration? My quick review of https://cx-freeze.readthedocs.io/en/latest/faq.html has so far not answered this.

0

There are 0 answers