[GH-ISSUE #534] Add option to exclude files & folders being copied to output (prevent whole Qt from being copied) #410

Open
opened 2026-02-26 12:21:30 +03:00 by kerem · 4 comments
Owner

Originally created by @ganego on GitHub (Jul 25, 2025).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/534

Originally assigned to: @brentvollebregt on GitHub.

I'm aware that in the help file there is a paragraph about venv, but that will hot help because I can exclude packages already with the options given.

My program uses Qt and PIL and for example 80 MB of Qt libraries get added of which I can easily delete 50 MB without interfering with my code. Same with PIL where I simply don't need parts of it. Or the win32com, pywin32_system32, Pythonwin folders seem to be unnecessary.

I propose options to be added to exclude whole folders and an option to exclude single files from being copied over to the output folder.

Thank you

Originally created by @ganego on GitHub (Jul 25, 2025). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/534 Originally assigned to: @brentvollebregt on GitHub. I'm aware that in the help file there is a paragraph about venv, but that will hot help because I can exclude packages already with the options given. My program uses Qt and PIL and for example 80 MB of Qt libraries get added of which I can easily delete 50 MB without interfering with my code. Same with PIL where I simply don't need parts of it. Or the `win32com`, `pywin32_system32`, `Pythonwin` folders seem to be unnecessary. I propose options to be added to exclude whole folders and an option to exclude single files from being copied over to the output folder. Thank you
Author
Owner

@github-actions[bot] commented on GitHub (Jul 25, 2025):

👋 Hi, just a reminder that if you haven't read the help post yet, give it a read to see if your issue is covered in it and make sure to follow the debugging section.

Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help post, video or create a new discussion.

<!-- gh-comment-id:3116675798 --> @github-actions[bot] commented on GitHub (Jul 25, 2025): 👋 Hi, just a reminder that if you haven't read [the help post](https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe/) yet, give it a read to see if your issue is covered in it and make sure to follow [the debugging section](https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe/#debugging). Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help [post](https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe/), [video](https://youtu.be/OZSZHmWSOeM) or create a [new discussion](https://github.com/brentvollebregt/auto-py-to-exe/discussions).
Author
Owner

@brentvollebregt commented on GitHub (Jul 25, 2025):

I understand you're point and get why it might be a good feature to be in auto-py-to-exe.

Just off the top of my head:

  • We won't really be able to provide or recommend to users a robust method of finding which folders and files can be removed, aside from "delete it and see if your application runs".
  • While "delete it and see if your application runs" might work for simple cases, packages (or even some applications) that dynamically import libraries might make it look like it was ok to remove at the beginning, but using the application more may show this is not the case.
  • If the underlying version of PyInstaller changes, the outputs might look different (has happened before in previous versions). So config now might not work later as the build output might look a bit different over time but still work the same.

If something like this was to go into auto-py-to-exe, it would only work with directory outputs (as opposed to one-file outputs). This is because we have no control over the package process and only get a single executable out at the end.

Of course you could have some "post processing" script to remove the files for you, but I understand if you are using the auto-py-to-exe config files and how it would be nice all in one place.

<!-- gh-comment-id:3117228827 --> @brentvollebregt commented on GitHub (Jul 25, 2025): I understand you're point and get why it might be a good feature to be in auto-py-to-exe. Just off the top of my head: - We won't really be able to provide or recommend to users a robust method of finding which folders and files can be removed, aside from "delete it and see if your application runs". - While "delete it and see if your application runs" might work for simple cases, packages (or even some applications) that dynamically import libraries might make it look like it was ok to remove at the beginning, but using the application more may show this is not the case. - If the underlying version of PyInstaller changes, the outputs might look different (has happened before in previous versions). So config now might not work later as the build output might look a bit different over time but still work the same. If something like this was to go into auto-py-to-exe, it would only work with directory outputs (as opposed to one-file outputs). This is because we have no control over the package process and only get a single executable out at the end. Of course you could have some "post processing" script to remove the files for you, but I understand if you are using the auto-py-to-exe config files and how it would be nice all in one place.
Author
Owner

@ganego commented on GitHub (Jul 25, 2025):

We won't really be able to provide or recommend to users a robust method of finding which folders and files can be removed [...]

That would indeed be the cherry on top if pyinstaller could properly detect only the needed libraries, but that probably won't happen.

While "delete it and see if your application runs" might work for simple cases

Yes this is how I do it, though the scope of my program isn't that big (it's an image viewer tailored to my needs).

Of course you could have some "post processing" script to remove the files for you, but I understand if you are using the auto-py-to-exe config files and how it would be nice all in one place.

Indeed. I can write a script to go over the files and delete them, but it would just be a nice 'all in one package' if it could be done directly.
Thinking about implementation, a file/directory chooser cannot really be used as it needs to be relative to the output folder anyway, so only relative paths to the _internal folder would make sense.
I very much like in your UI that you have single lines for each item with those "+" buttons and we don't have to add everything in one giant csv-string or so. It could be added in a way that if the entry ends on a path separator it will recursively delete the whole folder, else, just remove the file.

<!-- gh-comment-id:3117425699 --> @ganego commented on GitHub (Jul 25, 2025): > We won't really be able to provide or recommend to users a robust method of finding which folders and files can be removed [...] That would indeed be the cherry on top if pyinstaller could properly detect only the needed libraries, but that probably won't happen. > While "delete it and see if your application runs" might work for simple cases Yes this is how I do it, though the scope of my program isn't that big (it's an image viewer tailored to my needs). > Of course you could have some "post processing" script to remove the files for you, but I understand if you are using the auto-py-to-exe config files and how it would be nice all in one place. Indeed. I can write a script to go over the files and delete them, but it would just be a nice 'all in one package' if it could be done directly. Thinking about implementation, a file/directory chooser cannot really be used as it needs to be relative to the output folder anyway, so only relative paths to the `_internal` folder would make sense. I very much like in your UI that you have single lines for each item with those "+" buttons and we don't have to add everything in one giant csv-string or so. It could be added in a way that if the entry ends on a path separator it will recursively delete the whole folder, else, just remove the file.
Author
Owner

@brentvollebregt commented on GitHub (Jul 25, 2025):

Thinking about implementation, a file/directory chooser cannot really be used as it needs to be relative to the output folder anyway, so only relative paths to the _internal folder would make sense.

Yep, that makes sense.

It could be added in a way that if the entry ends on a path separator it will recursively delete the whole folder, else, just remove the file.

We can use pathlib to get a path reference, validate that it exists and then check if it's a file or directory using that. That allows for validation and should mostly work without much fuss.


nonPyinstallerOptions in the config would be a good place - maybe under something like postBundlePathsToDelete (a list of strings). The UI would sit in the "Settings" section under a new heading "Post Bundle Operations" between "Manually Provide Options" and "Configuration". Under the heading, "Paths To Delete" seems like a good label and it will use the same plus/minus setup used for other inputs.

I can't promise when I can get this in right now, but if you are open to making some changes, I can look at the PR.

<!-- gh-comment-id:3117465986 --> @brentvollebregt commented on GitHub (Jul 25, 2025): > Thinking about implementation, a file/directory chooser cannot really be used as it needs to be relative to the output folder anyway, so only relative paths to the `_internal` folder would make sense. Yep, that makes sense. > It could be added in a way that if the entry ends on a path separator it will recursively delete the whole folder, else, just remove the file. We can use pathlib to get a path reference, validate that it exists and then check if it's a file or directory using that. That allows for validation and should mostly work without much fuss. --- `nonPyinstallerOptions` in the config would be a good place - maybe under something like `postBundlePathsToDelete` (a list of strings). The UI would sit in the "Settings" section under a new heading "Post Bundle Operations" between "Manually Provide Options" and "Configuration". Under the heading, "Paths To Delete" seems like a good label and it will use the same plus/minus setup used for other inputs. I can't promise when I can get this in right now, but if you are open to making some changes, I can look at the PR.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#410
No description provided.