put DLLs, PYDs and modules under a sub-directory?

15 views
Skip to first unread message

进陆

unread,
Jul 8, 2020, 11:04:34 AM7/8/20
to PyInstaller

Currently, the pyinstaller copies many DLLs and PYDs to the `dist\main\` directory where `main.exe` lives. So it takes some time for a user to find the real application file to launch.

I know pyinstaller can produce a single executable file. But it will be at least 40M if wxPython is used.

My question is, how to tell pyinstaller to copy DLLs, PYDs and other python modules into a directory, for example `supporting`, so there is only 2 files, i.e. `main.exe` and `main.exe.manifest` under the `dist\main\` directory?

Thanks

Chris Barker

unread,
Jul 8, 2020, 12:03:34 PM7/8/20
to pyins...@googlegroups.com
FWIW, I think this is a great idea -- that dir can get VERY cluttered.

But it may be a challenge, particularly on Windows, as the model for dlls is to look for them "alongside" the exe they link to.

But maybe adding to PATH, or putting in a link or shortcut for the main.exe file could work?

-CHB


--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/81b5a35e-b240-4e8c-866a-c60fe5e13766o%40googlegroups.com.


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

bwoodsend

unread,
Jul 9, 2020, 3:27:16 AM7/9/20
to PyInstaller

I like this idea. It might be more complicated than it sounds though. As I understand it dlls and pyds are searched for differently.

**Dlls** are usually referenced by name and searched for in all the directories in PATH. Note that this the system `PATH` variable given by `os.environ["PATH"]` and not `sys.path`. This is the case for all the system dlls that PyInstaller lobs in. These dlls could in theory be tucked away elsewhere as long as that *elsewhere* folder is added to PATH on initialisation. But dlls can also referenced by their full path. Moving these would likely break whatever Python code is looking for them. This is more common in 3rd party Python libraries that use `ctypes` so most of them should already be inside their own folder anyway but not all.

**Pyds** work exactly the same way as Python's import system and should therefore be in `PYTHONPATH` (which is `sys.path` in Python). Again these could be moved provided
- The relative positioning of everything they reference is preserved.
- Their destination is added to `sys.path`.

An alternative option would be to add an outer folder containing the original build and launcher executable which would be a tiny executable containing a relative path to the actual executable inside your application. You can approximate this quite easily with a bat/shell script. And you could automate all this by appending code to do this to your spec file.

Reply all
Reply to author
Forward
0 new messages