block_cipher = None
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
)
a = Entrypoint("testapp", 'console_scripts', 'mytestscript1')
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='mytestscript1')
Сначала я собираю пакет с помощью python3 -m build, затем запускаю pyinstaller pyinstaller app.spec, что приводит к следующей ошибке:
27 INFO: PyInstaller: 4.10
27 INFO: Python: 3.8.10
34 INFO: Platform: Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-glibc2.29
35 INFO: UPX is not available.
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 8, in
sys.exit(run())
File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 124, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 58, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 803, in main
build(specfile, distpath, workpath, clean_build)
File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 725, in build
exec(code, spec_namespace)
File "app.spec", line 42, in
a = Entrypoint("testapp", 'console_scripts', 'mytestscript1', datas=[('testapp.egg-info/*','testapp.egg-info')])
File "app.spec", line 25, in Entrypoint
ep = pkg_resources.get_entry_info(dist, group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 500, in get_entry_info
return get_distribution(dist).get_entry_info(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 482, in get_distribution
dist = get_provider(dist)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 358, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'testapp' distribution was not found and is required by the application
Исключение вызывается, потому что pkg_resources.get_entry_info не находит мой дистрибутив, когда он запускается из pyinstaller, но когда я запускаю его из любого обычного скрипта в корне, он может найти без проблем:
Я пытаюсь создать исполняемый файл из дистрибутива setuptools, у меня есть следующая структура: [code]TEST-DIST ├── app.spec ├── my_package │ ├── __init__.py │ ├── __main__.py │ ├── script1.py │ └── script2.py └── setup.py [/code] Setup.py: [code]from importlib.metadata import entry_points import setuptools
setuptools.setup( name="testapp", version="0.0.1", author="Example Author", author_email="[email protected]", description="A small example package", url="https://github.com/pypa/sampleproject", project_urls={ "Bug Tracker": "https://github.com/pypa/sampleproject/issues", }, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], entry_points={'console_scripts': ["mytestscript1=my_package.script1:main", "mytestscript2=my_package.script2:main"]}, python_requires=">=3.6" ) [/code] app.spec, который использует этот сценарий для работы с инструментами настройки [code]block_cipher = None
# 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)
a = Entrypoint("testapp", 'console_scripts', 'mytestscript1') pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='mytestscript1') [/code] Сначала я собираю пакет с помощью python3 -m build, затем запускаю pyinstaller pyinstaller app.spec, что приводит к следующей ошибке:[code]27 INFO: PyInstaller: 4.10 27 INFO: Python: 3.8.10 34 INFO: Platform: Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-glibc2.29 35 INFO: UPX is not available. Traceback (most recent call last): File "/usr/local/bin/pyinstaller", line 8, in sys.exit(run()) File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 124, in run run_build(pyi_config, spec_file, **vars(args)) File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/__main__.py", line 58, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 803, in main build(specfile, distpath, workpath, clean_build) File "/home/admin/.local/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 725, in build exec(code, spec_namespace) File "app.spec", line 42, in a = Entrypoint("testapp", 'console_scripts', 'mytestscript1', datas=[('testapp.egg-info/*','testapp.egg-info')]) File "app.spec", line 25, in Entrypoint ep = pkg_resources.get_entry_info(dist, group, name) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 500, in get_entry_info return get_distribution(dist).get_entry_info(group, name) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 482, in get_distribution dist = get_provider(dist) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 358, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'testapp' distribution was not found and is required by the application [/code] Исключение вызывается, потому что pkg_resources.get_entry_info не находит мой дистрибутив, когда он запускается из pyinstaller, но когда я запускаю его из любого обычного скрипта в корне, он может найти без проблем: [code]>>> import pkg_resources >>> pkg_resources.get_entry_info("testapp", 'console_scripts', 'mytestscript1') EntryPoint.parse('mytestscript1 = my_package.script1:main') [/code] Ни одно из предложенных решений не помогло!
Я хочу развернуть приложение iOS в Apple Connect и в настройках выбрал «Сделать это приложение доступным на Mac». Поскольку лимит сертификатов «Распространение Apple» уже исчерпан, будет ли в этом сценарии работать сертификат «Распространение iOS»?...