diff --git a/news/237-platform-data-files b/news/237-platform-data-files new file mode 100644 index 0000000..a1d094e --- /dev/null +++ b/news/237-platform-data-files @@ -0,0 +1,19 @@ +### Enhancements + +* Only include `conda` and `menuinst` data files for the native platform. (#237) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 391e82f..b07ad7f 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -1,5 +1,6 @@ # -*- mode: python ; coding: utf-8 -*- import os +import platform import site import sys @@ -9,6 +10,23 @@ from PyInstaller.utils.hooks import collect_data_files, collect_submodules, copy from PyInstaller.utils.hooks import collect_submodules, copy_metadata + +def get_menuinst_data_files() -> list[tuple[str, str]]: + """Get sparse set of data files for menuinst to remove unneeded schemas and launchers.""" + data_files = [ + (os.path.join(sitepackages, 'menuinst', 'data', f'menuinst-{SCHEMA_VERSION}.default.json'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', f'menuinst-{SCHEMA_VERSION}.schema.json'), 'menuinst/data'), + ] + if sys.platform == "darwin": + macos_arch = os.environ.get("OSX_ARCH", platform.machine()) + data_files += [ + (os.path.join(sitepackages, 'menuinst', 'data', f'osx_launcher_{macos_arch}'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', f'appkit_launcher_{macos_arch}'), 'menuinst/data'), + ] + extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist") + return data_files + + # __file__ is not defined in the pyinstaller context, # so we will get it from sys.argv instead for arg in sys.argv: @@ -53,39 +71,29 @@ datas = [ (os.path.join(sitepackages, 'archspec', 'vendor', 'cpuid', 'LICENSE'), 'archspec/vendor/cpuid'), (os.path.join(sitepackages, 'conda', 'shell', 'bin', 'activate'), 'conda/shell/bin'), (os.path.join(sitepackages, 'conda', 'shell', 'bin', 'deactivate'), 'conda/shell/bin'), - (os.path.join(sitepackages, 'conda', 'shell', 'cli-32.exe'), 'conda/shell'), - (os.path.join(sitepackages, 'conda', 'shell', 'cli-64.exe'), 'conda/shell'), - (os.path.join(sitepackages, 'conda', 'shell', 'conda_icon.ico'), 'conda/shell'), (os.path.join(sitepackages, 'conda', 'shell', 'conda.xsh'), 'conda/shell'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', '_conda_activate.bat'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'activate.bat'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda_auto_activate.bat'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda_hook.bat'), 'conda/shell/condabin'), (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda-hook.ps1'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda.bat'), 'conda/shell/condabin'), (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'Conda.psm1'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'deactivate.bat'), 'conda/shell/condabin'), - (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'rename_tmp.bat'), 'conda/shell/condabin'), (os.path.join(sitepackages, 'conda', 'shell', 'etc', 'fish', 'conf.d', 'conda.fish'), 'conda/shell/etc/fish/conf.d'), (os.path.join(sitepackages, 'conda', 'shell', 'etc', 'profile.d', 'conda.csh'), 'conda/shell/etc/profile.d'), (os.path.join(sitepackages, 'conda', 'shell', 'etc', 'profile.d', 'conda.sh'), 'conda/shell/etc/profile.d'), - (os.path.join(sitepackages, 'conda', 'shell', 'Library', 'bin', 'conda.bat'), 'conda/shell/Library/bin'), - (os.path.join(sitepackages, 'conda', 'shell', 'Scripts', 'activate.bat'), 'conda/shell/Scripts'), - (os.path.join(sitepackages, 'menuinst', 'data', f'menuinst-{SCHEMA_VERSION}.default.json'), 'menuinst/data'), - (os.path.join(sitepackages, 'menuinst', 'data', f'menuinst-{SCHEMA_VERSION}.schema.json'), 'menuinst/data'), ] if sys.platform == "win32": datas += [ (os.path.join(os.getcwd(), 'entry_point_base.exe'), '.'), + (os.path.join(sitepackages, 'conda', 'shell', 'cli-32.exe'), 'conda/shell'), + (os.path.join(sitepackages, 'conda', 'shell', 'cli-64.exe'), 'conda/shell'), + (os.path.join(sitepackages, 'conda', 'shell', 'conda_icon.ico'), 'conda/shell'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', '_conda_activate.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'activate.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda_auto_activate.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda_hook.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'deactivate.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'rename_tmp.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'condabin', 'conda.bat'), 'conda/shell/condabin'), + (os.path.join(sitepackages, 'conda', 'shell', 'Library', 'bin', 'conda.bat'), 'conda/shell/Library/bin'), + (os.path.join(sitepackages, 'conda', 'shell', 'Scripts', 'activate.bat'), 'conda/shell/Scripts'), ] -elif sys.platform == "darwin": - datas += [ - (os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_arm64'), 'menuinst/data'), - (os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_x86_64'), 'menuinst/data'), - (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_arm64'), 'menuinst/data'), - (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_x86_64'), 'menuinst/data'), - ] - extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist") hiddenimports = [] packages = [ @@ -121,7 +129,10 @@ for name, module in conda_plugin_manager.list_name_plugin(): hiddenimports.extend(collect_submodules(package_name)) # collect_submodules does not look at __init__ hiddenimports.append(f"{package_name}.__init__") - datas.extend(collect_data_files(package_name)) + if package_name == "menuinst": + datas.extend(get_menuinst_data_files()) + else: + datas.extend(collect_data_files(package_name)) # metadata is needed for conda to find the plug-in datas.extend(copy_metadata(package_name))