|
1 | | -from cx_Freeze import setup, Executable |
2 | | - |
3 | 1 | import os |
4 | 2 | import sys |
5 | 3 | import glob |
6 | 4 | import fnmatch |
7 | 5 |
|
8 | | -# cx_Freeze options |
9 | | -# cx-freeze.readthedocs.io/en/latest/setup_script.html |
10 | | -# |
11 | | -base = None |
| 6 | +Executable = None |
12 | 7 | if sys.platform == 'win32': |
13 | | - base = "Win32GUI" |
14 | | - |
15 | | -company_name = "pjkundert" |
16 | | -product_name = "python-slip39" |
17 | | -icon_win = "images/SLIP-39.ico" |
18 | | - |
19 | | -shortcut = ( |
20 | | - "DesktopShortcut", # Shortcut |
21 | | - "DesktopFolder", # Directory_ |
22 | | - "SLIP-39", # Name |
23 | | - "TARGETDIR", # Component_ |
24 | | - "[TARGETDIR]SLIP-39.exe", # Target |
25 | | - None, # Arguments |
26 | | - None, # Description |
27 | | - None, # Hotkey |
28 | | - None, # Icon |
29 | | - None, # IconIndex |
30 | | - None, # ShowCmd |
31 | | - "TARGETDIR", # WkDir |
32 | | -) |
| 8 | + # We use cx_Freeze for executable/installer packaging on Windows, only, for now. |
| 9 | + from cx_Freeze import setup, Executable |
| 10 | + print( f"sys.platform {sys.platform}: Using cx_Freeze.setup" ) |
| 11 | +else: |
| 12 | + from setuptools import setup |
| 13 | + print( f"sys.platform {sys.platform}: Using setuptools.setup" ) |
33 | 14 |
|
34 | | -msi_data = dict( |
35 | | - Shortcut = [ |
36 | | - shortcut, |
37 | | - ], |
38 | | - #Icon = [ |
39 | | - # icon_win, |
40 | | - #] |
41 | | -) |
| 15 | +# |
| 16 | +# For various platforms, extra setup options are required. Collect them here |
| 17 | +# |
| 18 | +extra_options = {} |
42 | 19 |
|
43 | | -bdist_msi_options = dict( |
44 | | - add_to_path = True, |
45 | | - data = msi_data, |
46 | | - initial_target_dir = rf"[ProgramFilesFolder]\{company_name}\{product_name}", |
47 | | -) |
| 20 | +# |
| 21 | +# cx_Freeze options -- Windows .exe/.msi support |
| 22 | +# cx-freeze.readthedocs.io/en/latest/setup_script.html |
| 23 | +# |
| 24 | +mainscript = "SLIP-39.py" |
| 25 | +copyright = "Copyright (c) 2022 Perry Kundert", |
48 | 26 |
|
49 | | -build_exe_options = dict( |
50 | | - packages = [], |
51 | | - excludes = [], |
52 | | - include_msvcr = True, |
53 | | -) |
54 | | -executables = None |
55 | 27 | if sys.platform == 'win32': |
| 28 | + company_name = "pjkundert" |
| 29 | + product_name = "python-slip39" |
| 30 | + icon_win = "images/SLIP-39.ico" |
| 31 | + |
| 32 | + shortcut = ( |
| 33 | + "DesktopShortcut", # Shortcut |
| 34 | + "DesktopFolder", # Directory_ |
| 35 | + "SLIP-39", # Name |
| 36 | + "TARGETDIR", # Component_ |
| 37 | + "[TARGETDIR]SLIP-39.exe", # Target |
| 38 | + None, # Arguments |
| 39 | + None, # Description |
| 40 | + None, # Hotkey |
| 41 | + None, # Icon |
| 42 | + None, # IconIndex |
| 43 | + None, # ShowCmd |
| 44 | + "TARGETDIR", # WkDir |
| 45 | + ) |
| 46 | + |
| 47 | + msi_data = dict( |
| 48 | + Shortcut = [ |
| 49 | + shortcut, |
| 50 | + ], |
| 51 | + #Icon = [ |
| 52 | + # icon_win, |
| 53 | + #] |
| 54 | + ) |
| 55 | + |
| 56 | + bdist_msi_options = dict( |
| 57 | + add_to_path = True, |
| 58 | + data = msi_data, |
| 59 | + initial_target_dir = rf"[ProgramFilesFolder]\{company_name}\{product_name}", |
| 60 | + ) |
| 61 | + |
| 62 | + build_exe_options = dict( |
| 63 | + packages = [], |
| 64 | + excludes = [], |
| 65 | + include_msvcr = True, |
| 66 | + ) |
| 67 | + |
56 | 68 | executables = [ |
57 | 69 | Executable( |
58 | | - "SLIP-39.py", |
59 | | - copyright = "Copyright (c) 2022 Perry Kundert", |
60 | | - base = base, |
61 | | - icon = icon_win, |
| 70 | + mainscript, |
| 71 | + copyright = copyright, |
| 72 | + base = "Win32GUI", |
| 73 | + icon = icon_win, |
62 | 74 | ), |
63 | 75 | ] |
64 | 76 |
|
| 77 | + extra_options = dict( |
| 78 | + executables = executables, |
| 79 | + options = dict( |
| 80 | + bdist_msi = bdist_msi_options, |
| 81 | + build_exe = build_exe_options, |
| 82 | + ) |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +''' |
| 87 | +if sys.platform == 'darwin': |
| 88 | + # For py2{app,exe} App Generation. TODO: Does not work; use PyInstaller instead |
| 89 | + extra_options = dict( |
| 90 | + setup_requires = [ 'py2app' ], |
| 91 | + app = [ mainscript ], |
| 92 | + # Cross-platform applications generally expect sys.argv to |
| 93 | + # be used for opening files. |
| 94 | + # Don't use this with GUI toolkits, the argv |
| 95 | + # emulator causes problems and toolkits generally have |
| 96 | + # hooks for responding to file-open events. |
| 97 | + options = dict( |
| 98 | + py2app = dict( |
| 99 | + argv_emulation = True, |
| 100 | + iconfile = 'images/SLIP39.icns', |
| 101 | + includes = 'tkinter', |
| 102 | + ), |
| 103 | + ), |
| 104 | + ) |
| 105 | +elif sys.platform == 'win32': |
| 106 | + extra_options = dict( |
| 107 | + setup_requires = [ 'py2exe' ], |
| 108 | + app = [ mainscript ], |
| 109 | + ) |
| 110 | +else: |
| 111 | + extra_options = dict( |
| 112 | + # Normally unix-like platforms will use "setup.py install" |
| 113 | + # and install the main script as such |
| 114 | + scripts = [ mainscript ], |
| 115 | + ) |
| 116 | +''' |
| 117 | + |
65 | 118 |
|
| 119 | +# |
| 120 | +# All platforms |
| 121 | +# |
66 | 122 | HERE = os.path.dirname( os.path.abspath( __file__ )) |
67 | 123 |
|
68 | 124 | # Must work if setup.py is run in the source distribution context, or from |
|
245 | 301 | "Bug Tracker": "https://github.com/pjkundert/python-slip39/issues", |
246 | 302 | } |
247 | 303 |
|
248 | | -''' |
249 | | -# For py2{app,exe} App Generation. TODO: Does not work; use PyInstaller instead |
250 | | -mainscript = "SLIP39.py" |
251 | | -
|
252 | | -if sys.platform == 'darwin': |
253 | | - extra_options = dict( |
254 | | - setup_requires = [ 'py2app' ], |
255 | | - app = [ mainscript ], |
256 | | - # Cross-platform applications generally expect sys.argv to |
257 | | - # be used for opening files. |
258 | | - # Don't use this with GUI toolkits, the argv |
259 | | - # emulator causes problems and toolkits generally have |
260 | | - # hooks for responding to file-open events. |
261 | | - options = dict( |
262 | | - py2app = dict( |
263 | | - argv_emulation = True, |
264 | | - iconfile = 'images/SLIP39.icns', |
265 | | - includes = 'tkinter', |
266 | | - ), |
267 | | - ), |
268 | | - ) |
269 | | -elif sys.platform == 'win32': |
270 | | - extra_options = dict( |
271 | | - setup_requires = [ 'py2exe' ], |
272 | | - app = [ mainscript ], |
273 | | - ) |
274 | | -else: |
275 | | - extra_options = dict( |
276 | | - # Normally unix-like platforms will use "setup.py install" |
277 | | - # and install the main script as such |
278 | | - scripts = [ mainscript ], |
279 | | - ) |
280 | | -''' |
281 | | - |
282 | 304 | setup( |
283 | 305 | name = "slip39", |
284 | 306 | version = __version__, |
|
302 | 324 | url = "https://github.com/pjkundert/python-slip39", |
303 | 325 | classifiers = classifiers, |
304 | 326 | python_requires = ">=3.9", |
305 | | - executables = executables, |
306 | | - options = dict( |
307 | | - bdist_msi = bdist_msi_options, |
308 | | - build_exe = build_exe_options, |
309 | | - ), |
310 | | - #**extra_options |
| 327 | + **extra_options |
311 | 328 | ) |
0 commit comments