How do I use UPX with pyinstaller?

In addition to GlennS' comment: exact this behaviour is stated in the pyinstaller documentation. so this is not an undocumented accidental benefit in this regard.
See https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html#using-upx


Adding a new answer, since it appears that PyInstaller is more helpful now (in September 2019) than the current answer and comments suggest.

I see the output 934 INFO: UPX is available. early in the build if UPX is working.

Additionally, I can see many lines of output where PyInstaller is calling upx.

I didn't specify --upx-dir, but did have upx.exe available in my $PATH environment variable.


The UPX directory, not UPX executable needs to be specified:

e.g.:

pyinstaller myfile.py --upx-dir=..\upx391w -y --onefile