1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
# -*- mode: python -*-
import importlib.metadata
import os.path
import shutil
import subprocess
import sys
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = []
PROJECT_PATH = os.path.abspath(os.path.join(SPECPATH, "..", ".."))
datas.append((os.path.join(PROJECT_PATH, "README.rst"), "."))
datas.append((os.path.join(PROJECT_PATH, "LICENSE"), "."))
datas.append((os.path.join(PROJECT_PATH, "copyright"), "."))
datas += collect_data_files("silx.resources")
hiddenimports = ["hdf5plugin"]
hiddenimports += collect_submodules("fabio")
block_cipher = None
silx_a = Analysis(
["bootstrap.py"],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
cipher=block_cipher,
noarchive=False,
)
silx_pyz = PYZ(silx_a.pure, silx_a.zipped_data, cipher=block_cipher)
silx_exe = EXE(
silx_pyz,
silx_a.scripts,
silx_a.dependencies,
[],
exclude_binaries=True,
name="silx",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
icon="silx.ico",
)
silx_view_a = Analysis(
["bootstrap-silx-view.py"],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
cipher=block_cipher,
noarchive=False,
)
silx_view_pyz = PYZ(silx_view_a.pure, silx_view_a.zipped_data, cipher=block_cipher)
silx_view_exe = EXE(
silx_view_pyz,
silx_view_a.scripts,
silx_view_a.dependencies,
[],
exclude_binaries=True,
name="silx-view",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
icon="silx.ico",
)
silx_coll = COLLECT(
silx_view_exe,
silx_view_a.binaries,
silx_view_a.zipfiles,
silx_view_a.datas,
silx_exe,
silx_a.binaries,
silx_a.zipfiles,
silx_a.datas,
strip=False,
upx=False,
name="silx",
)
# Generate license file from current Python env
def create_license_file(filename: str):
import PyQt5.QtCore
with open(filename, "w") as f:
f.write(
f"""
This is free software.
This distribution of silx is provided under the
GNU General Public License v3 (https://www.gnu.org/licenses/gpl-3.0.en.html) since it includes PyQt5.
It includes mainy software packages with different licenses:
- Python ({sys.version}): PSF license, https://www.python.org/
- Qt ({PyQt5.QtCore.qVersion()}): GNU Lesser General Public License v3, https://www.qt.io/
"""
)
for dist in sorted(
importlib.metadata.distributions(), key=lambda d: d.name.lower()
):
license = dist.metadata.get("License")
homepage = dist.metadata.get("Home-page")
info = ", ".join(info for info in (license, homepage) if info)
f.write(f"- {dist.name} ({dist.version}): {info}\n")
create_license_file("LICENSE")
# Run innosetup
def innosetup():
from silx import strictversion
config_name = "create-installer.iss"
with open(config_name + ".template") as f:
content = f.read().replace("#Version", strictversion)
with open(config_name, "w") as f:
f.write(content)
subprocess.call(["iscc", os.path.join(SPECPATH, config_name)])
os.remove(config_name)
def make_zip():
"""Create a zip archive of the fat binary files"""
from silx import strictversion
base_name = os.path.join(SPECPATH, "artifacts", f"silx-{strictversion}-windows-application")
shutil.make_archive(
base_name,
format="zip",
root_dir=os.path.join(SPECPATH, "dist"),
base_dir="silx",
)
innosetup()
make_zip()
|