python-dotenvx 0.2.2__py3-none-any.whl → 0.2.4__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.2"
4
+ __version__ = "0.2.4"
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,73 @@
1
+ import os
2
+ import json
3
+ import shutil
4
+ import subprocess
5
+ import argparse
6
+
7
+ from dotenvx import __file__ as package_path
8
+
9
+ ERROR_MISSING_BINARY = "[MISSING_BINARY] missing dotenvx binary\n[MISSING_BINARY] https://github.com/dotenvx/dotenvx/issues/576"
10
+
1
11
  def load_dotenvx():
2
- raise NotImplementedError("go to [github.com/dotenvx/dotenvx] and follow python directions there")
12
+ output = get()
13
+
14
+ try:
15
+ parsed = json.loads(output)
16
+ for key, value in parsed.items():
17
+ os.environ[key] = value
18
+ return parsed
19
+ except Exception as e:
20
+ raise RuntimeError(f"Failed to parse dotenvx output: {e}")
21
+
22
+ def get():
23
+ binpath = binary()
24
+ output = subprocess.run(
25
+ [binpath, "get", "-pp"],
26
+ capture_output=True,
27
+ text=True,
28
+ check=True
29
+ )
30
+ return output.stdout.strip()
31
+
32
+ def binary():
33
+ local_bin = os.path.join(os.path.dirname(package_path), "bin", "dotenvx")
34
+ candidates = [local_bin, shutil.which("dotenvx")]
35
+
36
+ for candidate in candidates:
37
+ if candidate and os.path.isfile(candidate) and os.access(candidate, os.X_OK):
38
+ if is_stub_file(candidate):
39
+ continue
40
+ return candidate
41
+
42
+ print("[MISSING_BINARY] missing dotenvx binary")
43
+ print("[MISSING_BINARY] https://github.com/dotenvx/dotenvx/issues/576")
44
+ raise SystemExit(1)
45
+
46
+ def is_stub_file(path, max_stub_size=1024):
47
+ try:
48
+ return os.path.getsize(path) < max_stub_size
49
+ except OSError:
50
+ return False
51
+
52
+ def postinstall():
53
+ parser = argparse.ArgumentParser()
54
+ parser.add_argument("--os", help="Override OS", default="")
55
+ parser.add_argument("--arch", help="Override architecture", default="")
56
+ args = parser.parse_args()
57
+
58
+ bin_dir = os.path.join(os.path.dirname(__file__), "bin")
59
+ os.makedirs(bin_dir, exist_ok=True)
60
+
61
+ url = f"https://dotenvx.sh?directory={bin_dir}"
62
+ if args.os:
63
+ url += f"&os={args.os}"
64
+ if args.arch:
65
+ url += f"&arch={args.arch}"
66
+
67
+ try:
68
+ subprocess.run(
69
+ ["sh", "-c", f'curl -sfS "{url}" | sh'],
70
+ check=True
71
+ )
72
+ except subprocess.CalledProcessError as e:
73
+ raise SystemExit(e.returncode)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-dotenvx
3
- Version: 0.2.2
3
+ Version: 0.2.4
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,46 @@ 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
+ # or to specify the os-arch – useful for building binaries to a specific target such as linux-x86_64 on aws lambda
56
+ dotenvx-postinstall --os linux --arch x86_64
57
+ ```
58
+
59
+ Then use it in code.
60
+
49
61
  ```python
50
62
  # main.py
51
63
  import os
52
64
  from dotenvx import load_dotenvx
53
- load_dotenvx() # take environment variables from .env.
65
+ load_dotenvx() # take environment variables from .env.
54
66
 
55
67
  print(os.getenv("S3_BUCKET"))
56
68
  ```
57
69
 
58
70
  &nbsp;
59
71
 
60
-
61
72
  # Changelog
62
73
 
63
74
  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
75
 
65
- ## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.2.2...main)
76
+ ## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.2.4...main)
77
+
78
+ ## [0.2.4](https://github.com/dotenvx/dotenvx/compare/v0.2.3...v0.2.4)
79
+
80
+ ### Added
81
+
82
+ * Add the ability to specify the `os` and `arch` on `dotenvx-postinstall`
83
+
84
+ ## [0.2.3](https://github.com/dotenvx/dotenvx/compare/v0.2.2...v0.2.3)
85
+
86
+ ### Changed
87
+
88
+ * Patch `dotenvx` binary install across multiple edge cases
66
89
 
67
90
  ## [0.2.2](https://github.com/dotenvx/dotenvx/compare/v0.2.1...v0.2.2)
68
91
 
@@ -0,0 +1,10 @@
1
+ dotenvx/__init__.py,sha256=rfD8JBefABV8cPWOI8_po_RG6OMpFdrQTKRZSM5QipI,31
2
+ dotenvx/__version__.py,sha256=GF0tlg06fsiQD3qpsFjScp_xcCARdu-jKlquFBEN5UI,274
3
+ dotenvx/main.py,sha256=qWO2QPfedIujpanwMv6Px4Q2LirdUD0-xxiWZzPsgok,2085
4
+ dotenvx/bin/dotenvx,sha256=s7IfiwTOzpRT1vRD1UXsI-DXGv9Lp8ujCGyiwVExP8c,90
5
+ python_dotenvx-0.2.4.dist-info/licenses/LICENSE,sha256=Lt6wCRSMNsJJcSVkhx2Cl9kglLiOQXIo5PPOfbWe6e0,1498
6
+ python_dotenvx-0.2.4.dist-info/METADATA,sha256=L6fDSL5fszkqUZXdu8sv6f2MvjWc0HSFZrD05IDq3e8,2653
7
+ python_dotenvx-0.2.4.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
+ python_dotenvx-0.2.4.dist-info/entry_points.txt,sha256=Nub8f_4lO2T3-qRk5wJF-ii_fI9PQ7oPTjSI9e1OaXk,65
9
+ python_dotenvx-0.2.4.dist-info/top_level.txt,sha256=nl1TEgPiBhIp7rqusyvY6zlWLlcDroqH5GQxH-ImMkk,8
10
+ python_dotenvx-0.2.4.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=zs50u9BKLxIGTbjWXxBDZi7UYwiaMrP63fuO3GwOfVI,274
3
- dotenvx/main.py,sha256=PAJYK26M8MPEYeI86n0wCrCyma15sbbCbR-E_zhOuYg,121
4
- python_dotenvx-0.2.2.dist-info/licenses/LICENSE,sha256=Lt6wCRSMNsJJcSVkhx2Cl9kglLiOQXIo5PPOfbWe6e0,1498
5
- python_dotenvx-0.2.2.dist-info/METADATA,sha256=MoUJu9eLYANdm5o53ZnpW3LDkRaA4KdZbreeEf9nl-4,2039
6
- python_dotenvx-0.2.2.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
7
- python_dotenvx-0.2.2.dist-info/top_level.txt,sha256=nl1TEgPiBhIp7rqusyvY6zlWLlcDroqH5GQxH-ImMkk,8
8
- python_dotenvx-0.2.2.dist-info/RECORD,,