Using pyinstaller with setuptools package

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using pyinstaller with setuptools package

Vishesh Mangla
How to write the spec file? I just learned setuptools , made this first package and now I need to build an exe for windows.

I 'm on a win 10, using python=3.8.0 and using PiPy 's latest version of pyinstaller.

def Entrypoint(dist, group, name, **kwargs):
    import pkg_resources

    # get toplevel packages of distribution from metadata
    def get_toplevel(dist):
        distribution = pkg_resources.get_distribution(dist)
        if distribution.has_metadata('top_level.txt'):
            return list(distribution.get_metadata('top_level.txt').split())
            return []

    kwargs.setdefault('hiddenimports', [])
    packages = []
    for distribution in kwargs['hiddenimports']:
        packages += get_toplevel(distribution)

    kwargs.setdefault('pathex', [])
    # get the entry point
    ep = pkg_resources.get_entry_info(dist, group, name)
    # insert path of the egg at the verify front of the search path
    kwargs['pathex'] = [ep.dist.location] + kwargs['pathex']
    # script name must not be a valid module name to avoid name clashes on import
    script_path = os.path.join(workpath, name + '')
    print("creating script for entry point", dist, group, name)
    with open(script_path, 'w') as fh:
        print("import", ep.module_name, file=fh)
        print("%s.%s()" % (ep.module_name, '.'.join(ep.attrs)), file=fh)
        for package in packages:
            print("import", package, file=fh)

    return Analysis(
        [script_path] + kwargs.get('scripts', []),

Entrypoint('mailerkivy', 'gui_scripts', 'mailer.main')


import setuptools

        "gui_scripts": [
            "mailer = mailer.main:main",
        "build_for_windows":  ["pyinstaller>=4.2""pyinstaller"],


$ pyinstaller --clean --uac-admin b.spec
175 INFO: PyInstaller: 4.2
175 INFO: Python: 3.8.0
176 INFO: Platform: Windows-10-10.0.19041-SP0
188 INFO: UPX is not available.
189 INFO: Removing temporary files and cleaning cache in C:\Users\Dell\AppData\Roaming\pyinstaller
Traceback (most recent call last):
  File "c:\python38\lib\", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pyinstaller.exe\", line 9, in <module>
  File "c:\python38\lib\site-packages\PyInstaller\", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\python38\lib\site-packages\PyInstaller\", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\python38\lib\site-packages\PyInstaller\building\", line 725, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\python38\lib\site-packages\PyInstaller\building\", line 672, in build
    exec(code, spec_namespace)
  File "b.spec", line 36, in <module>
    Entrypoint('mailerkivy', 'gui_scripts', 'mailer.main')
  File "b.spec", line 19, in Entrypoint
    ep = pkg_resources.get_entry_info(dist, group, name)
  File "c:\python38\lib\site-packages\pkg_resources\", line 499, in get_entry_info
    return get_distribution(dist).get_entry_info(group, name)
  File "c:\python38\lib\site-packages\pkg_resources\", line 481, in get_distribution
    dist = get_provider(dist)
  File "c:\python38\lib\site-packages\pkg_resources\", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "c:\python38\lib\site-packages\pkg_resources\", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "c:\python38\lib\site-packages\pkg_resources\", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'mailerkivy' distribution was not found and is required by the application

You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit