py2exe access denied when trying to include sub directories

24 Views Asked by At

I am trying to include all the sub directories with its files into the .exe that is generated.

This works but its not including the files and it doesnt seem that copying them into the dist folder works.

from distutils.core import setup
from glob import glob
from setuptools import *
from PyQt5 import *
from PyQt5.Qt5 import *
from PyQt5.sip import *
import os, pathlib, random, json, math, sys, webbrowser, re, Globals, py2exe, platform
from time import sleep

SETUP_DICT = {

    'data_files': [
        ('platforms', glob(
            r'C:\Python311\Lib\site-packages\PyQt5\Qt5\plugins\platforms\qwindows.dll')),
    ],

    'packages': find_namespace_packages(
        where='*',
        include=['*']
    ),

    'package_dir': {"": "*"},

    'options': {
        'py2exe': {
            'includes': ["PyQt5", "PyQt5.Qt5", "PyQt5.sip"],
            'skip_archive': True,
        },
    },
}

if platform.system() == 'Windows':
    import py2exe
    SETUP_DICT['windows'] = [{
        'script': 'main.py',
        'icon_resources': [(0, r'logo.ico')]
    }]

setup(**SETUP_DICT)

If I try to add the folders I want to data_files, I get permission denied. I have already disabled my AV.

    'data_files': [
        ('platforms', glob(
            r'C:\Python311\Lib\site-packages\PyQt5\Qt5\plugins\platforms\qwindows.dll')),
        ('.', ['Combat', 'NPCdata', 'Documentation', 'Resources', 'SoL']),
    ],

This produces

error: [Errno 13] Permission denied: 'Combat'

Directory Structure

enter image description here

Without including them, I get this error

Traceback (most recent call last):
  File "main.py", line 598, in <module>
  File "main.py", line 246, in __init__
ModuleNotFoundError: No module named 'SoLFunctions'
0

There are 0 best solutions below