|
6 | 6 | __author__ = 'Simon Robinson' |
7 | 7 | __copyright__ = 'Copyright (c) 2024 Simon Robinson' |
8 | 8 | __license__ = 'Apache 2.0' |
9 | | -__package_version__ = '2025.4.27' # for pyproject.toml usage only - needs to be ast.literal_eval() compatible |
| 9 | +__package_version__ = '2025.5.30' # for pyproject.toml usage only - needs to be ast.literal_eval() compatible |
10 | 10 | __version__ = '-'.join('%02d' % int(part) for part in __package_version__.split('.')) # ISO 8601 (YYYY-MM-DD) |
11 | 11 |
|
12 | 12 | import abc |
@@ -172,7 +172,8 @@ class NSObject: |
172 | 172 | CENSOR_CREDENTIALS = True |
173 | 173 | CENSOR_MESSAGE = b'[[ Credentials removed from proxy log ]]' # replaces actual credentials; must be a byte-type string |
174 | 174 |
|
175 | | -script_path = sys.executable if getattr(sys, 'frozen', False) else os.path.realpath(__file__) # for pyinstaller etc |
| 175 | +FROZEN_PACKAGE = getattr(sys, 'frozen', False) or '__compiled__' in globals() # for pyinstaller/nuitka etc |
| 176 | +script_path = sys.executable if FROZEN_PACKAGE else os.path.realpath(__file__) |
176 | 177 | if sys.platform == 'darwin' and '.app/Contents/MacOS/' in script_path: # pyinstaller .app binary is within the bundle |
177 | 178 | if float('.'.join(platform.mac_ver()[0].split('.')[:2])) >= 10.12: # need a known path (due to App Translocation) |
178 | 179 | script_path = pathlib.Path('~/.%s/%s' % (APP_SHORT_NAME, APP_SHORT_NAME)).expanduser() |
@@ -275,7 +276,7 @@ def initialise(log_file=None): |
275 | 276 | if log_file or sys.platform == 'win32': |
276 | 277 | handler = logging.handlers.RotatingFileHandler( |
277 | 278 | log_file or os.path.join(os.getcwd() if __package__ is not None else |
278 | | - os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else |
| 279 | + os.path.dirname(sys.executable if FROZEN_PACKAGE else |
279 | 280 | os.path.realpath(__file__)), '%s.log' % APP_SHORT_NAME), |
280 | 281 | maxBytes=LOG_FILE_MAX_SIZE, backupCount=LOG_FILE_MAX_BACKUPS) |
281 | 282 | handler.setFormatter(logging.Formatter('%(asctime)s: %(message)s')) |
@@ -2800,8 +2801,8 @@ def init_platforms(self): |
2800 | 2801 | # proxy's handling of this signal may change in future if other actions are seen as more suitable |
2801 | 2802 | signal.signal(signal.SIGUSR1, lambda _signum, _fr: self.toggle_debug(Log.get_level() == logging.INFO)) |
2802 | 2803 |
|
2803 | | - # certificates are not imported automatically when packaged using pyinstaller - we need certifi |
2804 | | - if getattr(sys, 'frozen', False): |
| 2804 | + # certificates are not imported automatically when packaged using pyinstaller/nuitka - we need certifi |
| 2805 | + if FROZEN_PACKAGE: |
2805 | 2806 | if ssl.get_default_verify_paths().cafile is None and 'SSL_CERT_FILE' not in os.environ: |
2806 | 2807 | try: |
2807 | 2808 | import certifi |
@@ -3210,7 +3211,7 @@ def get_script_start_command(self, quote_args=True): |
3210 | 3211 | python_command = 'pythonw.exe'.join(python_command.rsplit('python.exe', 1)) |
3211 | 3212 |
|
3212 | 3213 | script_command = [python_command] |
3213 | | - if not getattr(sys, 'frozen', False): # no need for the script path if using pyinstaller |
| 3214 | + if not FROZEN_PACKAGE: # no need for the script path if using pyinstaller/nuitka |
3214 | 3215 | if __package__ is not None: |
3215 | 3216 | script_command.extend(['-m', APP_SHORT_NAME]) |
3216 | 3217 | else: |
|
0 commit comments