python-dotenvx 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl

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.
dotenvx/__version__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  __title__ = "python-dotenvx"
2
2
  __description__ = "[dotenvx.com] a better dotenv–from the creator of `dotenv`"
3
3
  __url__ = "https://github.com/dotenvx/python-dotenvx"
4
- __version__ = "0.2.1"
4
+ __version__ = "0.2.3"
5
5
  __author__ = "dotenv"
6
6
  __author_email__ = "mot@dotenvx.com"
7
7
  __license__ = "BSD-3-Clause"
dotenvx/bin/dotenvx ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ echo "[MISSING_BINARY] missing dotenvx binary. run: dotenvx-postinstall"
3
+ exit 1
dotenvx/main.py CHANGED
@@ -1,2 +1,61 @@
1
+ import os
2
+ import json
3
+ import shutil
4
+ import subprocess
5
+
6
+ from dotenvx import __file__ as package_path
7
+
8
+ ERROR_MISSING_BINARY = "[MISSING_BINARY] missing dotenvx binary\n[MISSING_BINARY] https://github.com/dotenvx/dotenvx/issues/576"
9
+
1
10
  def load_dotenvx():
2
- raise NotImplementedError("go to [github.com/dotenvx/dotenvx] and follow python directions there")
11
+ output = get()
12
+
13
+ try:
14
+ parsed = json.loads(output)
15
+ for key, value in parsed.items():
16
+ os.environ[key] = value
17
+ return parsed
18
+ except Exception as e:
19
+ raise RuntimeError(f"Failed to parse dotenvx output: {e}")
20
+
21
+ def get():
22
+ binpath = binary()
23
+ output = subprocess.run(
24
+ [binpath, "get", "-pp"],
25
+ capture_output=True,
26
+ text=True,
27
+ check=True
28
+ )
29
+ return output.stdout.strip()
30
+
31
+ def binary():
32
+ local_bin = os.path.join(os.path.dirname(package_path), "bin", "dotenvx")
33
+ candidates = [local_bin, shutil.which("dotenvx")]
34
+
35
+ for candidate in candidates:
36
+ if candidate and os.path.isfile(candidate) and os.access(candidate, os.X_OK):
37
+ if is_stub_file(candidate):
38
+ continue
39
+ return candidate
40
+
41
+ print("[MISSING_BINARY] missing dotenvx binary")
42
+ print("[MISSING_BINARY] https://github.com/dotenvx/dotenvx/issues/576")
43
+ raise SystemExit(1)
44
+
45
+ def is_stub_file(path, max_stub_size=1024):
46
+ try:
47
+ return os.path.getsize(path) < max_stub_size
48
+ except OSError:
49
+ return False
50
+
51
+ def postinstall():
52
+ bin_dir = os.path.join(os.path.dirname(package_path), "bin")
53
+ os.makedirs(bin_dir, exist_ok=True)
54
+
55
+ try:
56
+ subprocess.run(
57
+ ["sh", "-c", f"curl -sfS https://dotenvx.sh?directory={bin_dir} | sh"],
58
+ check=True
59
+ )
60
+ except subprocess.CalledProcessError as e:
61
+ raise SystemExit(e.returncode)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-dotenvx
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: [dotenvx.com] a better dotenv–from the creator of `dotenv`
5
5
  Home-page: https://github.com/dotenvx/python-dotenvx
6
6
  Author: dotenv
@@ -46,23 +46,43 @@ Install and use it in code just like `python-dotenv`.
46
46
  ```sh
47
47
  pip install python-dotenvx
48
48
  ```
49
+
50
+ Then run `dotenvx-postinstall` to install the `dotenvx` binary (python-dotenvx is a wrapper).
51
+
52
+ ```sh
53
+ dotenvx-postinstall
54
+ ```
55
+
56
+ Then use it in code.
57
+
49
58
  ```python
50
59
  # main.py
51
60
  import os
52
61
  from dotenvx import load_dotenvx
53
- load_dotenvx() # take environment variables from .env.
62
+ load_dotenvx() # take environment variables from .env.
54
63
 
55
64
  print(os.getenv("S3_BUCKET"))
56
65
  ```
57
66
 
58
67
  &nbsp;
59
68
 
60
-
61
69
  # Changelog
62
70
 
63
71
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
64
72
 
65
- ## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.2.1...main)
73
+ ## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.2.3...main)
74
+
75
+ ## [0.2.3](https://github.com/dotenvx/dotenvx/compare/v0.2.2...v0.2.3)
76
+
77
+ ### Changed
78
+
79
+ * Patch `dotenvx` binary install across multiple edge cases
80
+
81
+ ## [0.2.2](https://github.com/dotenvx/dotenvx/compare/v0.2.1...v0.2.2)
82
+
83
+ ### Changed
84
+
85
+ * Adjust installation of `dotenvx` binary on demand
66
86
 
67
87
  ## [0.2.1](https://github.com/dotenvx/dotenvx/compare/v0.2.1...v0.2.1)
68
88
 
@@ -0,0 +1,10 @@
1
+ dotenvx/__init__.py,sha256=rfD8JBefABV8cPWOI8_po_RG6OMpFdrQTKRZSM5QipI,31
2
+ dotenvx/__version__.py,sha256=Rpofp5Y61psI6C7xFGZBkHVTHn-9vlZ9PVqa4b2b0m4,274
3
+ dotenvx/main.py,sha256=1n17OLgvKn2EjM6ufY8DLKBhElKHgCOM04KXQtUhj8U,1738
4
+ dotenvx/bin/dotenvx,sha256=s7IfiwTOzpRT1vRD1UXsI-DXGv9Lp8ujCGyiwVExP8c,90
5
+ python_dotenvx-0.2.3.dist-info/licenses/LICENSE,sha256=Lt6wCRSMNsJJcSVkhx2Cl9kglLiOQXIo5PPOfbWe6e0,1498
6
+ python_dotenvx-0.2.3.dist-info/METADATA,sha256=UJbx-bGlxiVZhaKMFRtG_n3EBytYUm-n7VdsXp01fnw,2332
7
+ python_dotenvx-0.2.3.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
+ python_dotenvx-0.2.3.dist-info/entry_points.txt,sha256=Nub8f_4lO2T3-qRk5wJF-ii_fI9PQ7oPTjSI9e1OaXk,65
9
+ python_dotenvx-0.2.3.dist-info/top_level.txt,sha256=nl1TEgPiBhIp7rqusyvY6zlWLlcDroqH5GQxH-ImMkk,8
10
+ python_dotenvx-0.2.3.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dotenvx-postinstall = dotenvx.main:postinstall
@@ -1,8 +0,0 @@
1
- dotenvx/__init__.py,sha256=rfD8JBefABV8cPWOI8_po_RG6OMpFdrQTKRZSM5QipI,31
2
- dotenvx/__version__.py,sha256=HExXEc2D9idxM7CUX2x1d0B0OfJQlJuPI_x7yHMyBYQ,274
3
- dotenvx/main.py,sha256=PAJYK26M8MPEYeI86n0wCrCyma15sbbCbR-E_zhOuYg,121
4
- python_dotenvx-0.2.1.dist-info/licenses/LICENSE,sha256=Lt6wCRSMNsJJcSVkhx2Cl9kglLiOQXIo5PPOfbWe6e0,1498
5
- python_dotenvx-0.2.1.dist-info/METADATA,sha256=ze98vYJf12cezsDR946YbwX_6baPOXsZnGANpcDVNd8,1901
6
- python_dotenvx-0.2.1.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
7
- python_dotenvx-0.2.1.dist-info/top_level.txt,sha256=nl1TEgPiBhIp7rqusyvY6zlWLlcDroqH5GQxH-ImMkk,8
8
- python_dotenvx-0.2.1.dist-info/RECORD,,