-
Notifications
You must be signed in to change notification settings - Fork 0
/
pzero-linux.spec
125 lines (102 loc) · 3.61 KB
/
pzero-linux.spec
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
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files, collect_all, collect_entry_point
import pkgutil
import rasterio
import rasterio.sample
import platform
import os
import shutil
import shapely
import sys
import glob
system = platform.system()
cwd = os.getcwd()
path = os.path.join(cwd,f'installers/PZero_{system}')
if os.path.isdir(path):
shutil.rmtree(path)
# list all rasterio and fiona submodules, to include them in the package
additional_packages = list()
for package in pkgutil.iter_modules(rasterio.__path__, prefix="rasterio."):
additional_packages.append(package.name)
for package in pkgutil.iter_modules(rasterio.__path__, prefix="rasterio.sample"):
additional_packages.append(package.name)
for package in pkgutil.iter_modules(rasterio.__path__, prefix="rasterio.io"):
additional_packages.append(package.name)
for package in pkgutil.iter_modules(rasterio.__path__, prefix="rasterio._io"):
additional_packages.append(package.name)
rasterio_imports_paths = glob.glob(r'C:\ProgramData\Anaconda2\envs\wps_env36\Lib\site-packages\rasterio\*.py')
rasterio_imports = ['rasterio._shim']
for item in rasterio_imports_paths:
current_module_filename = os.path.split(item)[-1]
current_module_filename = 'rasterio.'+current_module_filename.replace('.py', '')
additional_packages.append(current_module_filename)
additional_packages.append('vtkmodules.all')
datas, binaries, hiddenimports = collect_all('pzero')
datas += collect_data_files('vedo')
datas += collect_data_files('cmocean')
datas += collect_data_files('shapely')
datas += collect_data_files('rasterio')
datas += collect_data_files('rasterio.sample')
datas += [("style/light_teal.qss", 'style' )]
datas += [("style/dark_teal.qss", 'style' )]
hiddenimports += additional_packages
if os.getenv('CONDA_PREFIX', ''):
# path to general lib directory
LIB_DIR = os.path.join(sys.prefix, 'lib')
# check if geos frozen lib name is existent
# at least with PyInstaller==3.4 it otherwise does not get created
if not glob.glob(os.path.join(LIB_DIR, 'libgeos_c-*.so.*')):
# otherwise create a new symlink to be copied to the frozen target
# conda package. (from shapely.geos source code)
LIB_FILE_NAME = 'libgeos_c.so'
# create symlink that shapely package can locate when in frozen state
LIB_SYM_PATH = os.path.join(LIB_DIR, 'libgeos_c-1.so.1')
command = f'ln -sf {LIB_FILE_NAME} {LIB_SYM_PATH}'
print(f"Created symlink {LIB_SYM_PATH} -> {LIB_FILE_NAME} and added to target.")
os.system(command)
else:
# if the library can already be found make sure it still gets included
# when bundling
LIB_SYM_PATH = glob.glob(os.path.join(LIB_DIR, 'libgeos_c-*.so.*'))[0]
# pass path of library to pyinstaller variable binaries [(source,target)]
binaries += [(LIB_SYM_PATH, '.')]
block_cipher = None
a = Analysis(
['pzero.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=['pzero/project_window.py'],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='pzero',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
shutil.move('dist/',path)
shutil.move('build/',path)