|
1 | | -from setuptools import setup |
2 | | - |
3 | 1 | import os |
4 | 2 | import sys |
5 | 3 | import glob |
6 | 4 | import fnmatch |
7 | 5 |
|
| 6 | +Executable = None |
| 7 | +if sys.platform == 'win32': |
| 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" ) |
| 14 | + |
| 15 | +# |
| 16 | +# For various platforms, extra setup options are required. Collect them here |
| 17 | +# |
| 18 | +extra_options = {} |
| 19 | + |
| 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", |
| 26 | + |
| 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 | + |
| 68 | + executables = [ |
| 69 | + Executable( |
| 70 | + mainscript, |
| 71 | + copyright = copyright, |
| 72 | + base = "Win32GUI", |
| 73 | + icon = icon_win, |
| 74 | + ), |
| 75 | + ] |
| 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 | + |
| 118 | + |
| 119 | +# |
| 120 | +# All platforms |
| 121 | +# |
8 | 122 | HERE = os.path.dirname( os.path.abspath( __file__ )) |
9 | 123 |
|
10 | 124 | # Must work if setup.py is run in the source distribution context, or from |
|
187 | 301 | "Bug Tracker": "https://github.com/pjkundert/python-slip39/issues", |
188 | 302 | } |
189 | 303 |
|
190 | | -''' |
191 | | -# For py2{app,exe} App Generation. TODO: Does not work; use PyInstaller instead |
192 | | -mainscript = "SLIP39.py" |
193 | | -
|
194 | | -if sys.platform == 'darwin': |
195 | | - extra_options = dict( |
196 | | - setup_requires = [ 'py2app' ], |
197 | | - app = [ mainscript ], |
198 | | - # Cross-platform applications generally expect sys.argv to |
199 | | - # be used for opening files. |
200 | | - # Don't use this with GUI toolkits, the argv |
201 | | - # emulator causes problems and toolkits generally have |
202 | | - # hooks for responding to file-open events. |
203 | | - options = dict( |
204 | | - py2app = dict( |
205 | | - argv_emulation = True, |
206 | | - iconfile = 'images/SLIP39.icns', |
207 | | - includes = 'tkinter', |
208 | | - ), |
209 | | - ), |
210 | | - ) |
211 | | -elif sys.platform == 'win32': |
212 | | - extra_options = dict( |
213 | | - setup_requires = [ 'py2exe' ], |
214 | | - app = [ mainscript ], |
215 | | - ) |
216 | | -else: |
217 | | - extra_options = dict( |
218 | | - # Normally unix-like platforms will use "setup.py install" |
219 | | - # and install the main script as such |
220 | | - scripts = [ mainscript ], |
221 | | - ) |
222 | | -''' |
223 | | - |
224 | 304 | setup( |
225 | 305 | name = "slip39", |
226 | 306 | version = __version__, |
|
244 | 324 | url = "https://github.com/pjkundert/python-slip39", |
245 | 325 | classifiers = classifiers, |
246 | 326 | python_requires = ">=3.9", |
247 | | - #**extra_options |
| 327 | + **extra_options |
248 | 328 | ) |
0 commit comments