4

After the successful packaging of my PySide app using PyInstaller, I've found lots of different *.so files in a package folder. I was surprised seeing libraries I don't use in my project, like: libQt53DAnimation.so, libQt53DCore.so, libQt5Multimedia.so and etc.

I didn't import them in source code and haven't include them in hidden imports.

As i have read, PyInstaller automatically finds all dependencies needed an app to run. If I delete them manually after the packaging, then my app running without any changes/troubles. That's points out that there is no need in them and they should not be treated as dependencies, aren't they?

So is there any way to exclude them while packaging

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Artem
  • 563
  • 3
  • 17

1 Answers1

2

If you are sure that they are not necessary for your application you can exclude them with the Analysis in the spec file. You simply need to add them as shown here https://pythonhosted.org/PyInstaller/spec-files.html#spec-file-operation.

Here is what you could do:

a.binaries = a.binaries - TOC([
  ('libQt53DAnimation.so', None, None),
  ('libQt53DCore.so', None, None),
  ('libQt5Multimedia.so', None, None),
])

There is also an --exclude-module EXCLUDES for excluding modules but, not sure how relevant it is for your case.

Unfortunately, pyinstaller includes certain optional dependenices as Hartmut Goebel explains here

PyInstaller does it's best to include only the needed modules - that's what PyInstaller is about :-). But many packages have optional dependencies which for your program might not be necessary, but are for other programs. PyInstaller can't know this and if PyInstaller would remove to much, other programs might fail. Please use option --exclude for this.

Please keep in mind, that alone Python's feature "full unicode support" add a lot of codecs modules, which look unecessary but are required for Python to work properly.

  • 1
    Thanks for the reply. It's nice that there's an opportunity to exclude libs manually, but it works in case I know that they are useless for my app (For example I don't use any 3d and multimedia in my project, so I can identify them with the lib name and delete later) But how to figure out other libs? How would I know that lib ```libQt5Concurrent.so``` is not a significant dependency of another lib? Checking it by deleting and seeing what is not working isn't a good idea, especially in big projects. – Artem Aug 13 '19 at 18:22
  • @Artem edited the answer to explain the reasoning behind adding extra DLLs – Vikramaditya Gaonkar Aug 13 '19 at 20:35
  • 1
    I don't think @Artem's comment has been answered. Does anyone know how to check whether a library is needed or depends on another required library? – Aaron Nov 28 '20 at 18:26
  • 1
    Two years passed, @Artem's comment is still not answered. – K.Mulier May 16 '22 at 21:17
  • 1
    Thanks for bringing it to the attention @K.Mulier. I think Artem's question is a valid separate question for SO itself? – Vikramaditya Gaonkar May 17 '22 at 11:03
  • Indeed @VikramadityaGaonkar – K.Mulier May 17 '22 at 14:43