Py2app - Filename too long

Recently tried to build a standalone app using PyQT5, ran into the issue of a recursive file name. The filename under the build directory keeps piling up. The build quits with an error "Filename too long"

So the fix was to not have the build and dist directories where the actual package code is i.e. it shouldn't be at the same level where setup.py file resides.

Here's a post detailing this: https://stackoverflow.com/a/29886668

So here's the final package hierarchy:

-- Directory
  -- SubDirectory
    -- app.py
    -- setup.py
  -- dist
  -- build

The dist and build need to be outside. The code in the answer, is correct. I am copying it here so it's easy to understand what the setup.py file looks like:

OPTIONS = {  
    "py2app": {
         "bdist_base": os.path.join(str(Path(os.get_cwd()).parent), 'build'),
         "dist_dir": os.path.join(str(Path(os.get_cwd()).parent), 'dist'),
    }
}
setup(app=['app.py'],  
      options=OPTIONS

This should eliminate that particular error. Happy coding.