Python cx_freeze Create dirs for included files in build

Is it possible to create dirs(folders) on cx_freeze build output, cause i include(include_files) many databases files and i want these to be in specific folder etc. I can take them easily from my folders.....

"include_files": ["databases/nations.txt","databases/newafrica.txt",
                    "databases/neweeurope.txt","databases/neweurope.txt","databases/newmeast.txt","graph.py",
                    "databases/newnamerica.txt","databases/plates.txt",
                    "databases/ACN/rigidA.txt","databases/ACN/rigidB.txt",
                    "databases/ACN/rigidC.txt","databases/ACN/rigidD.txt","databases/ACN/flexibleA.txt",
                    "databases/ACN/flexibleB.txt","databases/ACN/flexibleC.txt",
                    "databases/ACN/flexibleD.txt","alternates.xlsx",

but this will just copy all of them in exe build dir and its a mess. Thanks in advance.

Upvotes: 3

Views: 1446

Answers (1)

Xantium
Xantium

Reputation: 11605

There are several ways you can go around solving the problem.

Method 1 - Using include_files

Rather than ask for each individual text file you could just put the file name in the setup script and leave out the individual text files. In your case it would be like this:

"include_files": ["databases"]

This would copy the entire databases folder with everything in it into you build folder.

Absolute file paths work as well.

If you are going to use the installer feature (bdist_msi) this is the method to use.

You can copy sub folders only using "include_files": ["databases/ACN"]

Method 2 - Manually

Ok it's rather un-pythonic but the one way to do it is to copy it manually into the build folder.

Method 3 - Using the os module

Much the same as method two it would copy the folder into your build folder but instead of coping it manually it would use Python. You also have the option of using additional Python features as well.

Hope I was helpful.

Upvotes: 3

Related Questions