envstack 0.5.2__tar.gz → 0.5.3__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.
- envstack-0.5.3/LICENSE +12 -0
- {envstack-0.5.2 → envstack-0.5.3}/PKG-INFO +39 -7
- {envstack-0.5.2 → envstack-0.5.3}/README.md +37 -6
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/__init__.py +1 -1
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/cli.py +8 -1
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/env.py +29 -12
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/PKG-INFO +39 -7
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/SOURCES.txt +1 -0
- {envstack-0.5.2 → envstack-0.5.3}/setup.py +2 -2
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/config.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/exceptions.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/logger.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/path.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack/wrapper.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/dependency_links.txt +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/entry_points.txt +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/not-zip-safe +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/requires.txt +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/lib/envstack.egg-info/top_level.txt +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/setup.cfg +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/stack.env +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/tests/test_env.py +0 -0
- {envstack-0.5.2 → envstack-0.5.3}/tests/test_path.py +0 -0
envstack-0.5.3/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
envstack
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Ryan Galloway (ryan@rsgalloway.com)
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
10
|
+
* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: envstack
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.3
|
|
4
4
|
Summary: Stacked environment variable management system.
|
|
5
5
|
Home-page: http://github.com/rsgalloway/envstack
|
|
6
6
|
Author: Ryan Galloway
|
|
7
7
|
Author-email: ryan@rsgalloway.com
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
9
10
|
Requires-Dist: PyYAML>=5.1.2
|
|
10
11
|
|
|
11
12
|
envstack
|
|
@@ -217,18 +218,49 @@ $ envstack thing -- python -c "import os; print(os.environ['FOO'])"
|
|
|
217
218
|
bar
|
|
218
219
|
```
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
(and create an alias for convenience):
|
|
221
|
+
## Shells
|
|
222
222
|
|
|
223
|
+
In order to set an environment stack in your current shell, the stack must be
|
|
224
|
+
sourced (that's because Python processes and subshells cannot alter the
|
|
225
|
+
environment of the parent process).
|
|
226
|
+
|
|
227
|
+
To source the environment in your current shell, create an alias that sources
|
|
228
|
+
the output of the `--export` command:
|
|
229
|
+
|
|
230
|
+
#### bash
|
|
223
231
|
```bash
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
alias envstack-set='source <(envstack "$1" --export)';
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### cmd
|
|
236
|
+
```cmd
|
|
237
|
+
doskey envstack-set=for /f "usebackq" %%i in (`envstack --export $*`) do %%i
|
|
226
238
|
```
|
|
227
239
|
|
|
228
|
-
|
|
240
|
+
Then you can set the environment stack in your shell with the `envstack-set`
|
|
241
|
+
command. To clear the environment in your current shell, create an alias that
|
|
242
|
+
sources the output of the `--clear` command:
|
|
243
|
+
|
|
244
|
+
#### bash
|
|
245
|
+
```bash
|
|
246
|
+
alias envstack-clear='source <(envstack "$1" --clear)';
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### cmd
|
|
250
|
+
```cmd
|
|
251
|
+
doskey envstack-clear=for /f "usebackq" %%i in (`envstack --clear $*`) do %%i
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Create a function for convenience that does both in one command:
|
|
255
|
+
|
|
256
|
+
#### bash
|
|
257
|
+
```bash
|
|
258
|
+
envstack-init() { envstack-clear "$1"; envstack-set "$1"; }
|
|
259
|
+
```
|
|
229
260
|
|
|
261
|
+
#### cmd
|
|
230
262
|
```cmd
|
|
231
|
-
|
|
263
|
+
doskey envstack-init=envstack-clear $* & envstack-set $*
|
|
232
264
|
```
|
|
233
265
|
|
|
234
266
|
## Config
|
|
@@ -207,18 +207,49 @@ $ envstack thing -- python -c "import os; print(os.environ['FOO'])"
|
|
|
207
207
|
bar
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
(and create an alias for convenience):
|
|
210
|
+
## Shells
|
|
212
211
|
|
|
212
|
+
In order to set an environment stack in your current shell, the stack must be
|
|
213
|
+
sourced (that's because Python processes and subshells cannot alter the
|
|
214
|
+
environment of the parent process).
|
|
215
|
+
|
|
216
|
+
To source the environment in your current shell, create an alias that sources
|
|
217
|
+
the output of the `--export` command:
|
|
218
|
+
|
|
219
|
+
#### bash
|
|
213
220
|
```bash
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
alias envstack-set='source <(envstack "$1" --export)';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### cmd
|
|
225
|
+
```cmd
|
|
226
|
+
doskey envstack-set=for /f "usebackq" %%i in (`envstack --export $*`) do %%i
|
|
216
227
|
```
|
|
217
228
|
|
|
218
|
-
|
|
229
|
+
Then you can set the environment stack in your shell with the `envstack-set`
|
|
230
|
+
command. To clear the environment in your current shell, create an alias that
|
|
231
|
+
sources the output of the `--clear` command:
|
|
232
|
+
|
|
233
|
+
#### bash
|
|
234
|
+
```bash
|
|
235
|
+
alias envstack-clear='source <(envstack "$1" --clear)';
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### cmd
|
|
239
|
+
```cmd
|
|
240
|
+
doskey envstack-clear=for /f "usebackq" %%i in (`envstack --clear $*`) do %%i
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Create a function for convenience that does both in one command:
|
|
244
|
+
|
|
245
|
+
#### bash
|
|
246
|
+
```bash
|
|
247
|
+
envstack-init() { envstack-clear "$1"; envstack-set "$1"; }
|
|
248
|
+
```
|
|
219
249
|
|
|
250
|
+
#### cmd
|
|
220
251
|
```cmd
|
|
221
|
-
|
|
252
|
+
doskey envstack-init=envstack-clear $* & envstack-set $*
|
|
222
253
|
```
|
|
223
254
|
|
|
224
255
|
## Config
|
|
@@ -73,10 +73,15 @@ def parse_args():
|
|
|
73
73
|
default=config.DEFAULT_NAMESPACE,
|
|
74
74
|
help="the environment stack to use (default '%s')" % config.DEFAULT_NAMESPACE,
|
|
75
75
|
)
|
|
76
|
+
parser.add_argument(
|
|
77
|
+
"--clear",
|
|
78
|
+
action="store_true",
|
|
79
|
+
help="generate shell unset commands for a given stack",
|
|
80
|
+
)
|
|
76
81
|
parser.add_argument(
|
|
77
82
|
"--export",
|
|
78
83
|
action="store_true",
|
|
79
|
-
help="generate export commands for
|
|
84
|
+
help="generate shell export commands for a given stack",
|
|
80
85
|
)
|
|
81
86
|
parser.add_argument(
|
|
82
87
|
"-p",
|
|
@@ -133,6 +138,8 @@ def main():
|
|
|
133
138
|
sources = build_sources(args.namespace)
|
|
134
139
|
for source in sources:
|
|
135
140
|
print(source)
|
|
141
|
+
elif args.clear:
|
|
142
|
+
print(export(args.namespace, config.SHELL, clear=True))
|
|
136
143
|
elif args.export:
|
|
137
144
|
print(export(args.namespace, config.SHELL))
|
|
138
145
|
elif command:
|
|
@@ -504,33 +504,50 @@ def expandvars(var, env=None, recursive=False):
|
|
|
504
504
|
return EnvVar(var).expand(env, recursive=recursive)
|
|
505
505
|
|
|
506
506
|
|
|
507
|
-
def export(name, shell="bash", resolve=False, scope=None):
|
|
507
|
+
def export(name, shell="bash", resolve=False, scope=None, clear=False):
|
|
508
508
|
"""Returns environment commands that can be sourced.
|
|
509
509
|
|
|
510
510
|
$ source <(envstack --export)
|
|
511
511
|
|
|
512
|
-
|
|
512
|
+
or to clear existing values:
|
|
513
|
+
|
|
514
|
+
$ source <(envstack --clear)
|
|
515
|
+
|
|
516
|
+
List of shell names: bash, sh, tcsh, cmd, pwsh
|
|
513
517
|
(see output of config.detect_shell()).
|
|
514
518
|
|
|
515
|
-
:param name: stack namespace
|
|
516
|
-
:param shell: name of shell (default: bash)
|
|
517
|
-
:param resolve: resolve values (default: True)
|
|
518
|
-
:param scope: environment scope (default: cwd)
|
|
519
|
-
:
|
|
519
|
+
:param name: stack namespace.
|
|
520
|
+
:param shell: name of shell (default: bash).
|
|
521
|
+
:param resolve: resolve values (default: True).
|
|
522
|
+
:param scope: environment scope (default: cwd).
|
|
523
|
+
:param clear: clear existing values (default: False).
|
|
524
|
+
:returns: shell commands as string.
|
|
520
525
|
"""
|
|
521
526
|
env = load_environ(name, scope=scope)
|
|
522
527
|
expList = list()
|
|
523
528
|
for k, v in env.items():
|
|
524
529
|
if resolve:
|
|
525
530
|
v = expandvars(v, env, recursive=False)
|
|
526
|
-
if shell == "bash":
|
|
527
|
-
|
|
531
|
+
if shell == "bash" or shell == "sh":
|
|
532
|
+
if clear:
|
|
533
|
+
expList.append(f"unset {k}")
|
|
534
|
+
else:
|
|
535
|
+
expList.append(f'export {k}="{v}"')
|
|
528
536
|
elif shell == "tcsh":
|
|
529
|
-
|
|
537
|
+
if clear:
|
|
538
|
+
expList.append(f"unsetenv {k}")
|
|
539
|
+
else:
|
|
540
|
+
expList.append(f'setenv {k}:"{v}"')
|
|
530
541
|
elif shell == "cmd":
|
|
531
|
-
|
|
542
|
+
if clear:
|
|
543
|
+
expList.append(f"set {k}=")
|
|
544
|
+
else:
|
|
545
|
+
expList.append(f'set {k}="{v}"')
|
|
532
546
|
elif shell == "pwsh":
|
|
533
|
-
|
|
547
|
+
if clear:
|
|
548
|
+
expList.append(f"Remove-Item Env:{k}")
|
|
549
|
+
else:
|
|
550
|
+
expList.append(f'$env:{k}="{v}"')
|
|
534
551
|
expList.sort()
|
|
535
552
|
exp = "\n".join(expList)
|
|
536
553
|
return exp
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: envstack
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.3
|
|
4
4
|
Summary: Stacked environment variable management system.
|
|
5
5
|
Home-page: http://github.com/rsgalloway/envstack
|
|
6
6
|
Author: Ryan Galloway
|
|
7
7
|
Author-email: ryan@rsgalloway.com
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
9
10
|
Requires-Dist: PyYAML>=5.1.2
|
|
10
11
|
|
|
11
12
|
envstack
|
|
@@ -217,18 +218,49 @@ $ envstack thing -- python -c "import os; print(os.environ['FOO'])"
|
|
|
217
218
|
bar
|
|
218
219
|
```
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
(and create an alias for convenience):
|
|
221
|
+
## Shells
|
|
222
222
|
|
|
223
|
+
In order to set an environment stack in your current shell, the stack must be
|
|
224
|
+
sourced (that's because Python processes and subshells cannot alter the
|
|
225
|
+
environment of the parent process).
|
|
226
|
+
|
|
227
|
+
To source the environment in your current shell, create an alias that sources
|
|
228
|
+
the output of the `--export` command:
|
|
229
|
+
|
|
230
|
+
#### bash
|
|
223
231
|
```bash
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
alias envstack-set='source <(envstack "$1" --export)';
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### cmd
|
|
236
|
+
```cmd
|
|
237
|
+
doskey envstack-set=for /f "usebackq" %%i in (`envstack --export $*`) do %%i
|
|
226
238
|
```
|
|
227
239
|
|
|
228
|
-
|
|
240
|
+
Then you can set the environment stack in your shell with the `envstack-set`
|
|
241
|
+
command. To clear the environment in your current shell, create an alias that
|
|
242
|
+
sources the output of the `--clear` command:
|
|
243
|
+
|
|
244
|
+
#### bash
|
|
245
|
+
```bash
|
|
246
|
+
alias envstack-clear='source <(envstack "$1" --clear)';
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### cmd
|
|
250
|
+
```cmd
|
|
251
|
+
doskey envstack-clear=for /f "usebackq" %%i in (`envstack --clear $*`) do %%i
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Create a function for convenience that does both in one command:
|
|
255
|
+
|
|
256
|
+
#### bash
|
|
257
|
+
```bash
|
|
258
|
+
envstack-init() { envstack-clear "$1"; envstack-set "$1"; }
|
|
259
|
+
```
|
|
229
260
|
|
|
261
|
+
#### cmd
|
|
230
262
|
```cmd
|
|
231
|
-
|
|
263
|
+
doskey envstack-init=envstack-clear $* & envstack-set $*
|
|
232
264
|
```
|
|
233
265
|
|
|
234
266
|
## Config
|
|
@@ -74,7 +74,7 @@ class PostInstallCommand(install):
|
|
|
74
74
|
|
|
75
75
|
setup(
|
|
76
76
|
name="envstack",
|
|
77
|
-
version="0.5.
|
|
77
|
+
version="0.5.3",
|
|
78
78
|
description="Stacked environment variable management system.",
|
|
79
79
|
long_description=long_description,
|
|
80
80
|
long_description_content_type="text/markdown",
|
|
@@ -85,7 +85,7 @@ setup(
|
|
|
85
85
|
packages=find_packages("lib"),
|
|
86
86
|
entry_points={
|
|
87
87
|
"console_scripts": [
|
|
88
|
-
"envstack
|
|
88
|
+
"envstack=envstack.cli:main",
|
|
89
89
|
],
|
|
90
90
|
},
|
|
91
91
|
install_requires=[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|