pyhabitat 1.0.21__tar.gz → 1.0.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyhabitat might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: A lightweight library for detecting system environment, GUI, and build properties.
5
5
  Author-email: George Clayton Bennett <george.bennett@memphistn.gov>
6
6
  License-Expression: MIT
@@ -352,9 +352,10 @@ def is_elf(exec_path: Path | str | None = None, debug: bool = False, suppress_de
352
352
  # Check the magic number: The first four bytes of an ELF file are 0x7f, 'E', 'L', 'F' (b'\x7fELF').
353
353
  # This is the most reliable way to determine if the executable is a native binary wrapper (like PyInstaller's).
354
354
  magic_bytes = read_magic_bytes(exec_path, 4, debug and not suppress_debug)
355
-
355
+ if magic_bytes is None:
356
+ return False
356
357
  return magic_bytes == b'\x7fELF'
357
- except Exception:
358
+ except (OSError, IOError) as e:
358
359
  if debug:
359
360
  logging.debug("False (Exception during file check)")
360
361
  return False
@@ -370,7 +371,7 @@ def is_pyz(exec_path: Path | str | None = None, debug: bool = False, suppress_de
370
371
  # Check if the extension is PYZ
371
372
  if not str(exec_path).endswith(".pyz"):
372
373
  if debug:
373
- logging.debug("False (Not a .pyz file)")
374
+ logging.debug("is_pyz()=False (Not a .pyz file)")
374
375
  return False
375
376
 
376
377
  if not _check_if_zip(exec_path):
@@ -390,11 +391,17 @@ def is_windows_portable_executable(exec_path: Path | str | None = None, debug: b
390
391
  exec_path, is_valid = _check_executable_path(exec_path, debug and not suppress_debug)
391
392
  if not is_valid:
392
393
  return False
393
- magic_bytes = read_magic_bytes(exec_path, 2, debug and not suppress_debug)
394
- result = magic_bytes.startswith(b"MZ")
394
+ try:
395
+ magic_bytes = read_magic_bytes(exec_path, 2, debug and not suppress_debug)
396
+ if magic_bytes is None:
397
+ return False
398
+ result = magic_bytes.startswith(b"MZ")
399
+ return result
400
+ except (OSError, IOError) as e:
401
+ if debug:
402
+ logging.debug(f"is_windows_portable_executable() = False (Exception: {e})")
403
+ return False
395
404
 
396
- return result
397
-
398
405
  def is_macos_executable(exec_path: Path | str | None = None, debug: bool = False, suppress_debug: bool =False) -> bool:
399
406
  """
400
407
  Checks if the currently running executable is a macOS/Darwin Mach-O binary,
@@ -409,7 +416,8 @@ def is_macos_executable(exec_path: Path | str | None = None, debug: bool = False
409
416
  # Common ones are: b'\xfe\xed\xfa\xce' (32-bit) or b'\xfe\xed\xfa\xcf' (64-bit)
410
417
 
411
418
  magic_bytes = read_magic_bytes(exec_path, 4, debug and not suppress_debug)
412
-
419
+ if magic_bytes is None:
420
+ return False
413
421
  # Common Mach-O magic numbers (including their reversed-byte counterparts)
414
422
  MACHO_MAGIC = {
415
423
  b'\xfe\xed\xfa\xce', # MH_MAGIC
@@ -423,11 +431,12 @@ def is_macos_executable(exec_path: Path | str | None = None, debug: bool = False
423
431
 
424
432
  return is_macho
425
433
 
426
- except Exception:
434
+ except (OSError, IOError) as e:
427
435
  if debug:
428
- logging.debug("False (Exception during file check)")
436
+ logging.debug("is_macos_executable() = False (Exception during file check)")
429
437
  return False
430
-
438
+
439
+
431
440
  def is_pipx(exec_path: Path | str | None = None, debug: bool = False, suppress_debug: bool = True) -> bool:
432
441
  """Checks if the executable is running from a pipx managed environment."""
433
442
  exec_path, is_valid = _check_executable_path(exec_path, debug and not suppress_debug, check_pipx=False)
@@ -826,4 +835,4 @@ def main(path=None, debug=False):
826
835
  print("")
827
836
 
828
837
  if __name__ == "__main__":
829
- main(debug=True)
838
+ main(debug=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: A lightweight library for detecting system environment, GUI, and build properties.
5
5
  Author-email: George Clayton Bennett <george.bennett@memphistn.gov>
6
6
  License-Expression: MIT
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "pyhabitat"
9
- version = "1.0.21"
9
+ version = "1.0.23"
10
10
  #dynamic = ["version"] #
11
11
  authors = [
12
12
  { name="George Clayton Bennett", email="george.bennett@memphistn.gov" },
@@ -30,6 +30,6 @@ pyhabitat = "pyhabitat.cli:run_cli"
30
30
  where = ["."]
31
31
  include = ["pyhabitat*"]
32
32
 
33
- [tool.setuptools_scm]
34
- # This tells setuptools_scm to look at your git history/tags for the version
35
- write_to = "pyhabitat/_version.py"
33
+ #[tool.setuptools_scm]
34
+ # This tells setuptools_scm to look at the git history/tags for the version
35
+ #write_to = "pyhabitat/_version.py"
File without changes
File without changes
File without changes
File without changes