pyhabitat 1.0.9__tar.gz → 1.0.11__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.9
3
+ Version: 1.0.11
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
@@ -27,7 +27,7 @@ Stop writing verbose `sys.platform` and environment variable checks. Use **`pyha
27
27
 
28
28
  ---
29
29
 
30
- Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py).
30
+ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py). 🌐
31
31
 
32
32
  ---
33
33
 
@@ -36,10 +36,12 @@ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabita
36
36
  ```bash
37
37
  pip install pyhabitat
38
38
  ```
39
+
39
40
  ---
40
41
 
41
42
  <details>
42
- <summary> Motivation </summary>
43
+ <summary> 🧠 Motivation </summary>
44
+
43
45
  This library is especially useful for **leveraging Python in mobile environments** (`Termux` on Android and `iSH` on iOS), which often have particular limitations and require special handling. For example, it helps automate work-arounds like using **localhost plotting** when `matplotlib` is unavailable or **web-based interfaces** when `tkinter` is missing.
44
46
 
45
47
  Our team is fundamentally driven by enabling mobile computing for true utility applications, leveraging environments like Termux (Android) and iSH (iOS). This includes highly practical solutions, such as deploying a lightweight Python web server (e.g., Flask, http.server, FastAPI) directly on a handset, or orchestrating full-stack, utility-grade applications that allow technicians to manage data and systems right from their mobile device in a way that is cross-platform and not overly catered to the App Store.
@@ -119,6 +121,10 @@ Key Question: "What could I do next?"
119
121
 
120
122
  The module exposes all detection functions directly for easy access.
121
123
 
124
+ ### 0\. Current Use
125
+
126
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
127
+
122
128
  ### 1\. Checking Environment and Build Type
123
129
 
124
130
  ```python
@@ -12,7 +12,7 @@ Stop writing verbose `sys.platform` and environment variable checks. Use **`pyha
12
12
 
13
13
  ---
14
14
 
15
- Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py).
15
+ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py). 🌐
16
16
 
17
17
  ---
18
18
 
@@ -21,10 +21,12 @@ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabita
21
21
  ```bash
22
22
  pip install pyhabitat
23
23
  ```
24
+
24
25
  ---
25
26
 
26
27
  <details>
27
- <summary> Motivation </summary>
28
+ <summary> 🧠 Motivation </summary>
29
+
28
30
  This library is especially useful for **leveraging Python in mobile environments** (`Termux` on Android and `iSH` on iOS), which often have particular limitations and require special handling. For example, it helps automate work-arounds like using **localhost plotting** when `matplotlib` is unavailable or **web-based interfaces** when `tkinter` is missing.
29
31
 
30
32
  Our team is fundamentally driven by enabling mobile computing for true utility applications, leveraging environments like Termux (Android) and iSH (iOS). This includes highly practical solutions, such as deploying a lightweight Python web server (e.g., Flask, http.server, FastAPI) directly on a handset, or orchestrating full-stack, utility-grade applications that allow technicians to manage data and systems right from their mobile device in a way that is cross-platform and not overly catered to the App Store.
@@ -104,6 +106,10 @@ Key Question: "What could I do next?"
104
106
 
105
107
  The module exposes all detection functions directly for easy access.
106
108
 
109
+ ### 0\. Current Use
110
+
111
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
112
+
107
113
  ### 1\. Checking Environment and Build Type
108
114
 
109
115
  ```python
@@ -449,22 +449,54 @@ def web_browser_is_available() -> bool:
449
449
  return False
450
450
 
451
451
  # --- LAUNCH MECHANISMS BASED ON ENVIRONMENT ---
452
- def open_text_file_in_default_app(filepath):
453
- """Opens a file with its default application based on the OS."""
452
+ def open_text_file_for_editing(filepath):
453
+ """
454
+ Opens a file with the environment's default application (Windows, Linux, macOS)
455
+ or a guaranteed console editor (nano) in constrained environments (Termux, iSH)
456
+ after ensuring line-ending compatibility.
457
+ """
454
458
  if is_windows():
455
459
  os.startfile(filepath)
456
460
  elif is_termux():
461
+ # Install dependencies if missing (Termux pkg returns non-zero if already installed, so no check=True)
462
+ subprocess.run(['pkg','install', 'dos2unix', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
463
+ _run_dos2unix(filepath)
457
464
  subprocess.run(['nano', filepath])
458
465
  elif is_ish_alpine():
459
- subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
466
+ # Install dependencies if missing (apk returns 0 if already installed, so check=True is safe)
467
+ subprocess.run(['apk','add', 'dos2unix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
468
+ subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
469
+ _run_dos2unix(filepath)
460
470
  subprocess.run(['nano', filepath])
471
+ # --- Standard Unix-like Systems (Conversion + Default App) ---
461
472
  elif is_linux():
473
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
462
474
  subprocess.run(['xdg-open', filepath])
475
+
463
476
  elif is_apple():
477
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
464
478
  subprocess.run(['open', filepath])
465
479
  else:
466
480
  print("Unsupported operating system.")
467
-
481
+
482
+ """Why Not Use check=True on Termux:
483
+ The pkg utility in Termux is a wrapper around Debian's apt. When you run pkg install <package>, if the package is already installed, the utility often returns an exit code of 100 (or another non-zero value) to indicate that no changes were made because the package was already present.
484
+ """
485
+
486
+ def _run_dos2unix(filepath):
487
+ """Attempt to run dos2unix, failing silently if not installed."""
488
+ try:
489
+ # We rely on shutil.which not being needed, as this is a robust built-in utility on most targets
490
+ # The command won't raise an exception unless the process itself fails, not just if the utility isn't found.
491
+ # We also don't use check=True here to allow silent failure if the utility is missing (e.g., minimalist Linux).
492
+ subprocess.run(['dos2unix', filepath], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
493
+ except FileNotFoundError:
494
+ # This will be raised if 'dos2unix' is not on the system PATH
495
+ pass
496
+ except Exception:
497
+ # Catch other subprocess errors (e.g. permission issues)
498
+ pass
499
+
468
500
  def _get_pipx_paths():
469
501
  """
470
502
  Returns the configured/default pipx binary and home directories.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.9
3
+ Version: 1.0.11
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
@@ -27,7 +27,7 @@ Stop writing verbose `sys.platform` and environment variable checks. Use **`pyha
27
27
 
28
28
  ---
29
29
 
30
- Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py).
30
+ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabitat/blob/main/pyhabitat/environment.py). 🌐
31
31
 
32
32
  ---
33
33
 
@@ -36,10 +36,12 @@ Read the code on [github](https://github.com/City-of-Memphis-Wastewater/pyhabita
36
36
  ```bash
37
37
  pip install pyhabitat
38
38
  ```
39
+
39
40
  ---
40
41
 
41
42
  <details>
42
- <summary> Motivation </summary>
43
+ <summary> 🧠 Motivation </summary>
44
+
43
45
  This library is especially useful for **leveraging Python in mobile environments** (`Termux` on Android and `iSH` on iOS), which often have particular limitations and require special handling. For example, it helps automate work-arounds like using **localhost plotting** when `matplotlib` is unavailable or **web-based interfaces** when `tkinter` is missing.
44
46
 
45
47
  Our team is fundamentally driven by enabling mobile computing for true utility applications, leveraging environments like Termux (Android) and iSH (iOS). This includes highly practical solutions, such as deploying a lightweight Python web server (e.g., Flask, http.server, FastAPI) directly on a handset, or orchestrating full-stack, utility-grade applications that allow technicians to manage data and systems right from their mobile device in a way that is cross-platform and not overly catered to the App Store.
@@ -119,6 +121,10 @@ Key Question: "What could I do next?"
119
121
 
120
122
  The module exposes all detection functions directly for easy access.
121
123
 
124
+ ### 0\. Current Use
125
+
126
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
127
+
122
128
  ### 1\. Checking Environment and Build Type
123
129
 
124
130
  ```python
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "pyhabitat"
9
- version = "1.0.9"
9
+ version = "1.0.11"
10
10
  #dynamic = ["version"] #
11
11
  authors = [
12
12
  { name="George Clayton Bennett", email="george.bennett@memphistn.gov" },
File without changes
File without changes