https://stackoverflow.com/questions/48884766/pyinstaller-on-a-setuptools-package
None of the answers seem to work given here.
```b.spec
# -*- mode: python -*-
block_cipher = None
def Entrypoint(dist, group, name,
scripts=None, pathex=None, hiddenimports=None,
hookspath=None, excludes=None, runtime_hooks=None):
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())
else:
return []
hiddenimports = hiddenimports or []
packages = []
for distribution in hiddenimports:
packages += get_toplevel(distribution)
scripts = scripts or []
pathex = pathex or []
# 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
pathex = [ep.dist.location] + pathex
# script name must not be a valid module name to avoid name clashes on
import
script_path = os.path.join(workpath, name + '-script.py')
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] + scripts, pathex, hiddenimports,
hookspath, excludes, runtime_hooks)
a = Entrypoint('mailerkivy',
'gui_scripts',
'mailer',
)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Mailer',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False ,
icon='./src/mailer.ico' )
```
I even tried putting pathex=
pathex=[r'C:\Users\Dell\OneDrive\Desktop\MailerKivy\src\mailer',
r'C:\Users\Dell\OneDrive\Desktop\MailerKivy',
r'C:\Users\Dell\OneDrive\Desktop\MailerKivy\src\mailerkivy.egg-info'
],
It didn't work then too.
On Thursday, April 1, 2021 at 2:37:42 PM UTC+5:30 VISHESH MANGLA wrote:
> After building the exe , this error pops up if I run it from the cmd.
> Looks the same , most of it.
>
>
> 1. $ Traceback (most recent call last):
> 2. File "C:\Python38\Scripts\mailer-script.pyw", line 6, in <module>
> 3. from pkg_resources import load_entry_point
> 4. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py", line
> 3251, in <module>
> 5. def _initialize_master_working_set():
> 6. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py", line
> 3234, in _call_aside
> 7. f(*args, **kwargs)
> 8. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py", line
> 3263, in _initialize_master_working_set
> 9. working_set = WorkingSet._build_master()
> 10. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py",
> line 583, in _build_master
> 11. ws.require(__requires__)
> 12. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py",
> line 900, in require
> 13. needed = self.resolve(parse_requirements(requirements))
> 14. File "C:\Python38\lib\site-packages\pkg_resources\__init__.py",
> line 786, in resolve
> 15. raise DistributionNotFound(req, requirers)
> 16. pkg_resources.DistributionNotFound: The 'mailer' distribution was
> not found and is required by the application
>
>
>
>
> On Thursday, April 1, 2021 at 1:21:22 PM UTC+5:30 VISHESH MANGLA wrote:
>
>>
>> I do not have knowledge of the jargons here. I created a python package
>> with setup.py the first time and now I want to create a windows installer.
>>
>> https://github.com/pyinstaller/pyinstaller/issues
>>
>>
>>
>> ```setup.py
>>
>> import setuptools
>>
>>
>> setuptools.setup(
>> name="mailerkivy",
>> version="0.1.1",
>> url="..",
>> author="..",
>> author_email="..",
>> python_requires='>=3.7',
>> packages=setuptools.find_packages("src"),
>> package_dir={"": "src"},
>> entry_points={
>> "gui_scripts": [
>> "mailer = mailer.main:main",
>> ],
>> },
>> setup_requires="setuptools",
>> install_requires=[
>> "kivy>=2.0.0",
>> "beautifulsoup4>=4.9.3",
>> "docxtpl>=0.11.3",
>> "pywin32>=300",
>> "plyer>=2.0.0"
>>
>> ],
>> extras_require={
>> "build_for_windows": ["pyinstaller>=4.2", "pyinstaller"],
>> }
>> )
>>
>>
>>
>>
>> ```
>>
>>
>>
>> ```b.spec
>>
>> 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())
>> else:
>> 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 + '-script.py')
>> 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', []),
>> **kwargs
>> )
>>
>> Entrypoint('mailerkivy', 'gui_scripts', 'mailer.main')
>> ```
>>
>> ```traceback
>> Dell DESKTOP-QRTJB1E MINGW64 ~/OneDrive/Desktop/MailerKivy (master)
>> $ 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\runpy.py", line 192, in _run_module_as_main
>> return _run_code(code, main_globals, None,
>> File "c:\python38\lib\runpy.py", line 85, in _run_code
>> exec(code, run_globals)
>> File "C:\Python38\Scripts\pyinstaller.exe\__main__.py", line 9, in
>> <module>
>> File "c:\python38\lib\site-packages\PyInstaller\__main__.py", line 114,
>> in run
>> run_build(pyi_config, spec_file, **vars(args))
>> File "c:\python38\lib\site-packages\PyInstaller\__main__.py", line 65,
>> in run_build
>> PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
>> File
>> "c:\python38\lib\site-packages\PyInstaller\building\build_main.py", line
>> 725, in main
>> build(specfile, kw.get('distpath'), kw.get('workpath'),
>> kw.get('clean_build'))
>> File
>> "c:\python38\lib\site-packages\PyInstaller\building\build_main.py", 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\__init__.py", line
>> 499, in get_entry_info
>> return get_distribution(dist).get_entry_info(group, name)
>> File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line
>> 481, in get_distribution
>> dist = get_provider(dist)
>> File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line
>> 357, in get_provider
>> return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
>> File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line
>> 900, in require
>> needed = self.resolve(parse_requirements(requirements))
>> File "c:\python38\lib\site-packages\pkg_resources\__init__.py", 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/a352d50b-6ba0-442e-ad00-77f73bbaf468n%40googlegroups.com.