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.
- python_setenv-0.0.3.dist-info/METADATA +66 -0
- python_setenv-0.0.3.dist-info/RECORD +6 -0
- python_setenv-0.0.3.dist-info/licenses/LICENSE +21 -0
- setenv/__init__.py +1 -1
- python_setenv-0.0.1.dist-info/METADATA +0 -7
- python_setenv-0.0.1.dist-info/RECORD +0 -5
- {python_setenv-0.0.1.dist-info → python_setenv-0.0.3.dist-info}/WHEEL +0 -0
|
@@ -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
|
+
<!---[](https://github.com/ffreemt/python-setenv/actions)-->
|
|
12
|
+
# python-setenv
|
|
13
|
+
[](https://github.com/ffreemt/python-setenv/actions)[](https://www.python.org/downloads/)[](https://github.com/psf/black)[](https://opensource.org/licenses/MIT)[](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
|
+
<!----->
|
|
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
|
+
<!----->
|
|
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
|
@@ -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,,
|
|
File without changes
|