As stated in the title:; I have a "small" python exe GUI program generated by pyinstaller which creates a tcl folder that has 820 files (mostly tzdata). Any chance of reducing this number?

It takes a long time to copy the program because of all the tiny files.

Number of files in folder

I've used the datetime library. I just need the date and time to pop up on a pdf that I'm printing, so doesn't need to be that fancy. I just need the time on the computer :)

I can use "--onefile" to just get the .exe, but that takes too long to open.

Program is only for Windows atm.

3

There are 3 answers

0
Error5 On

If you don't mind adding a native dynamic library (dll/so), you can use tclvfs, a Tcl extension, and store those 820 files in a zip file.

AFAIK, tclvfs doesn't extract the files to a temp directory like pyinstaller's "--onefile" (unless you try to load a native extension), so it should be fast.

Walkthrough

Acquire the extension

You can either build from source or grab the Windows binaries from msys2. The msys2 binaries are a bit outdated (from 2013) but will still work.

Extract the package under the tcl directory. You only need pkgIndex.tcl, vfs.tcl, vfs142.dll, vfslib.tcl, vfsUtils.tcl, and zipvfs.tcl for mounting zip files. Put them under .../tcl/tclvfs.

Zip the loose files

Pack all the original files in the tcl directory into library.zip. You can do the same with tk (under the tk directory).

Those files need to stay in the tcl directory: init.tcl, package.tcl, tclIndex, tm.tcl (for loading packages).

Patch init.tcl

Add the following to init.tcl to load library.zip.

package require vfs::zip
# mount library.zip
vfs::zip::Mount [file join $::tcl_library library.zip] $::tcl_library
# reload index
auto_load_index

Now you have 11 files instead of 820.

0
Ευάγγελος Γρηγορόπουλος On

Generally the 'blunt' approach is to attack the problem by deleting the files(or some files) and see if your programm works as intended without any bugs.That can be some times rather complicating and time consuming,and some times not even possible. Libraries like pyinstaller and cx_freeze tends to be super inclusive of files that you don't even need so the programm is guaranteed to work.

Generally i advise you to create an installer for your programm(like Inno Setup) that will look really more professional and will diminish your current problem.

Also python supports ziped libraries that can drastically discreaze the size of the app on some libraries.Look one of my own question on the topic Python3 compiled App Decrease Size with zip?.

Have fun!

1
Donal Fellows On

You can almost certainly delete the http1.0 and opt0.4 directories outright. They're obsolete packages included for backward compatibility only.

The *.tcl and tclIndex files should be left (except for parray.tcl, which you likely don't need).

Of the encoding, msgs and tzdata directories, if you're deploying in a restricted set of locations, you can delete a lot of that; you only need the encodings, message catalogs and timezone definitions that you actually use when running. Thus, if you're only supporting English speakers in the USA, you can delete a very large fraction of the files. (If you're not using Tcl to format or parse dates at all, you don't need any timezone definitions.) The main encoding that you must retain is the one that the scripts are written in! (NB: support for the UTF-8 and ISO8859-1 encodings, and the UTF-16-derived ones used for talking to the Windows API, are all built in directly to Tcl; you can't remove support for them.)

Which things you can remove depend on your application and where you deploy it. That's why we can't tell you outright which files to delete.