python-setenv 0.0.1__py3-none-any.whl → 0.0.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.
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-setenv
3
+ Version: 0.0.3
4
+ Summary: Set env (e.g. HF_TOKEN) from colab/kaggle secrets or dotenv .env env files
5
+ Author-email: ffreemt <yucongo+fmt@gmail.com>
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.8
8
+ Requires-Dist: python-dotenv>=1.0.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ <!---[![pytest](https://github.com/ffreemt/python-setenv/actions/workflows/routine-tests.yml/badge.svg)](https://github.com/ffreemt/python-setenv/actions)-->
12
+ # python-setenv
13
+ [![pytest](https://github.com/ffreemt/python-setenv/actions/workflows/routine-tests.yml/badge.svg)](https://github.com/ffreemt/python-setenv/actions)[![python](https://img.shields.io/static/v1?label=python+&message=3.8%2B&color=blue)](https://www.python.org/downloads/)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/python-setenv.svg)](https://badge.fury.io/py/python-setenv)
14
+
15
+ Set an environ variable from colab, kaggle or dotenv (search default .env/dotenv/env)
16
+
17
+ ### Why `python-setenv`
18
+
19
+ colab and kaggle both provide a way to manage secrets (typically API tokens).
20
+
21
+ `python-setenv` is mainly for running ipynb (jupyter notebook) files in colab/kaggle or cloud instance when we need to set an environ variable, for example, `HF_TOKEN` to download models or datasets from huggingdace hub, other scenarios include `WANDB_API_KEY` or `NGROK_AUTHCODE` or `OPENAI_API_KEY` etc.
22
+
23
+ When running an ipynb in a cloud instance, we may use `dotenv` (`pip install python-dotenv`) to set environ varibales based on `.env`.
24
+
25
+ ### Install it
26
+ ```
27
+ pip install python-setenv
28
+ ```
29
+
30
+ ### Setup Secrets or Upload `.env`
31
+
32
+ * In colab, set Secrets
33
+
34
+ <img src="https://github.com/ffreemt/python-setenv/raw/main/img/colab.png" width="300" />
35
+
36
+ <!---![](img/colab.png)-->
37
+
38
+ * In kaggle, set Add-ons/Secrets
39
+
40
+ <img src="https://github.com/ffreemt/python-setenv/raw/main/img/kaggle.png" width="300" />
41
+
42
+ <!---![](./img/kaggle.png)-->
43
+
44
+ * In other jupyter environ/cloud instance, upload .env, with contents, e.g.
45
+ ```
46
+ HF_TOKEN=...
47
+ WANDB_API_KEY=...
48
+ ```
49
+ In some cases, files start with a dot are not allowed. Rename `.env` to `dotenv` or `env` instead, `setenv` will auto-search for `.env`, `dotenv` and `env`.
50
+
51
+ ## Use it
52
+ ```
53
+ from setenv import setenv
54
+
55
+ # e.g.
56
+ setenv("HF_TOKEN")
57
+ setenv("WANDB_API_KEY")
58
+ setenv("NGROK_AUTHCODE")
59
+ ```
60
+
61
+ Sometimes we want to set HF_TOKEN to HF_TOKEN_W (with write-permission).
62
+ ```
63
+ from setenv import setenv
64
+ setenv(env_var="HF_TOKEN", source_var="HF_TOKEN_W")
65
+ ```
66
+ This is effectively equivalent to `os.environ["HF_TOKEN"] = get_secret("HF_TOKEN_W")` when in colab or kaggle, or `os.environ["HF_TOKEN"] = dotenv.dotenv_values().get("HF_TOKEN_W")`.
@@ -0,0 +1,6 @@
1
+ setenv/__init__.py,sha256=bWbPU486WbijWBQr7dY-TCsFZWPGq-sLnOraJVEBrSs,3558
2
+ setenv/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ python_setenv-0.0.3.dist-info/METADATA,sha256=stAS5jTx1vKeEOiyc8cv9EDHnPTP9fFJmABih_t_gD4,2847
4
+ python_setenv-0.0.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ python_setenv-0.0.3.dist-info/licenses/LICENSE,sha256=_uswrdKCdw7w6eijHhtUmEBb6YEg7uk5lYnf_FJpS3o,1085
6
+ python_setenv-0.0.3.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ffreemt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
setenv/__init__.py CHANGED
@@ -11,7 +11,7 @@ from pathlib import Path
11
11
  from dotenv import dotenv_values, find_dotenv
12
12
  # from loguru import logger
13
13
 
14
- __version__ = "0.0.1"
14
+ __version__ = "0.0.3"
15
15
 
16
16
 
17
17
  def hello() -> str:
@@ -1,7 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-setenv
3
- Version: 0.0.1
4
- Summary: Set env (e.g. HF_TOKEN) from colab/kaggle secrets or dotenv .env env files
5
- Author-email: ffreemt <yucongo+fmt@gmail.com>
6
- Requires-Python: >=3.10
7
- Requires-Dist: python-dotenv>=1.2.1
@@ -1,5 +0,0 @@
1
- setenv/__init__.py,sha256=ZRkV6G4CkdVIZwsVXXtn7jrP8YSIHKPDLOifoI7z8rc,3558
2
- setenv/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- python_setenv-0.0.1.dist-info/METADATA,sha256=ZT4-kPoD3xl7iNF_aV6exyWxGX-QpK0YmcW8zUDFD9s,247
4
- python_setenv-0.0.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
- python_setenv-0.0.1.dist-info/RECORD,,