envstack 0.7.1__tar.gz → 0.7.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.
Files changed (25) hide show
  1. {envstack-0.7.1/lib/envstack.egg-info → envstack-0.7.3}/PKG-INFO +86 -11
  2. {envstack-0.7.1 → envstack-0.7.3}/README.md +85 -10
  3. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/__init__.py +1 -1
  4. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/cli.py +5 -6
  5. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/env.py +163 -112
  6. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/util.py +63 -4
  7. {envstack-0.7.1 → envstack-0.7.3/lib/envstack.egg-info}/PKG-INFO +86 -11
  8. {envstack-0.7.1 → envstack-0.7.3}/setup.py +1 -1
  9. {envstack-0.7.1 → envstack-0.7.3}/tests/test_cmds.py +82 -3
  10. {envstack-0.7.1 → envstack-0.7.3}/tests/test_env.py +107 -0
  11. {envstack-0.7.1 → envstack-0.7.3}/tests/test_util.py +2 -1
  12. {envstack-0.7.1 → envstack-0.7.3}/LICENSE +0 -0
  13. {envstack-0.7.1 → envstack-0.7.3}/dist.json +0 -0
  14. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/config.py +0 -0
  15. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/exceptions.py +0 -0
  16. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/logger.py +0 -0
  17. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/path.py +0 -0
  18. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack/wrapper.py +0 -0
  19. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/SOURCES.txt +0 -0
  20. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/dependency_links.txt +0 -0
  21. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/entry_points.txt +0 -0
  22. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/not-zip-safe +0 -0
  23. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/requires.txt +0 -0
  24. {envstack-0.7.1 → envstack-0.7.3}/lib/envstack.egg-info/top_level.txt +0 -0
  25. {envstack-0.7.1 → envstack-0.7.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: envstack
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Stacked environment variable management system
5
5
  Home-page: http://github.com/rsgalloway/envstack
6
6
  Author: Ryan Galloway
@@ -34,6 +34,7 @@ Environment variable management system.
34
34
  | Variable expansion modifiers | Supports bash-like variable expansion modifiers, allowing you to set default values for variables and override them in the environment or by higher scope stacks. |
35
35
  | Platform-specific variables | Stacks can have platform-specific variables and values. This allows you to define different values for variables based on the platform. |
36
36
  | Variable references | Variables can reference other variables, allowing for more flexibility and dynamic value assignment. |
37
+ | Multi-line values | Supports variables with multi-line values. |
37
38
  | Includes | Stack files can include other stacks, making it easy to reuse and combine different stacks. |
38
39
  | Python API | Provides a Python API that allows you to initialize and work with environment stacks programmatically. Easily initialize pre-defined environments with Python scripts, tools, and wrappers. |
39
40
  | Running commands | Allows you to run command line executables inside an environment stack, providing a convenient way to execute commands with a pre-defined environment. |
@@ -127,6 +128,43 @@ scope to lower scope, left to right):
127
128
  $ envstack [STACK [STACK ...]]
128
129
  ```
129
130
 
131
+ #### Executing Scripts
132
+
133
+ Environment stack files are also executable scripts that can be run directly:
134
+
135
+
136
+ ```bash
137
+ $ ./env/test.env
138
+ DEPLOY_ROOT=${ROOT}/${STACK}
139
+ ENV=${STACK}
140
+ ENVPATH=${DEPLOY_ROOT}/env:${ROOT}/prod/env
141
+ HELLO=${HELLO:=world}
142
+ LOG_LEVEL=DEBUG
143
+ PATH=${DEPLOY_ROOT}/bin:${ROOT}/prod/bin:${PATH}
144
+ PYTHONPATH=${DEPLOY_ROOT}/lib/python:${ROOT}/prod/lib/python:${PYTHONPATH}
145
+ ROOT=/mnt/pipe
146
+ STACK=test
147
+ ```
148
+
149
+ Run commands inside a specific environment stack file:
150
+
151
+ ```bash
152
+ $ ./env/test.env -- <command>
153
+ ```
154
+
155
+ For example:
156
+
157
+ ```bash
158
+ $ ./env/hello.env -- echo {HELLO}
159
+ world
160
+ ```
161
+
162
+ Export a specific environment stack file:
163
+
164
+ ```bash
165
+ $ ./env/hello.env --export
166
+ ```
167
+
130
168
  ## Setting Values
131
169
 
132
170
  Envstack uses bash-like variable expansion modifiers. Setting `$VAR` to a fixed
@@ -180,40 +218,67 @@ goodbye
180
218
  Several example or starter stacks are available in the [env folder of the
181
219
  envstack repo](https://github.com/rsgalloway/envstack/tree/master/env).
182
220
 
183
- To create a blank environment stack, create a new namespaced .env file and
184
- declare some variables.
221
+ To create a blank environment stack, create a new envstack file and declare some
222
+ variables.
185
223
 
186
- For example `foo.env` (the stack name is "foo"):
224
+ Create a new stack file called "foobar.env" and make it executable (note: at
225
+ least one VAR needs to be defined under all):
226
+
227
+ #### foobar.env
187
228
 
188
229
  ```yaml
230
+ #!/usr/bin/env envstack
231
+
189
232
  all: &default
190
233
  FOO: bar
191
234
  BAR: ${FOO}
235
+ darwin:
236
+ <<: *default
237
+ linux:
238
+ <<: *default
239
+ windows:
240
+ <<: *default
241
+ ```
242
+
243
+ Make it executable
244
+
245
+ ```bash
246
+ $ chmod +x ./foobar.env
192
247
  ```
193
248
 
194
- To see the resolved environment for the `foo` environment stack, run:
249
+ To see the resolved environment for the `foobar` stack, run:
195
250
 
196
251
  ```bash
197
- $ envstack foo
252
+ $ envstack foobar
198
253
  FOO=bar
199
254
  BAR=$FOO
200
255
  ```
201
256
 
257
+ or execute it directly:
258
+
259
+ ```bash
260
+ $ ./foobar.env
261
+ ```
262
+
202
263
  To see resolved values:
203
264
 
204
265
  ```bash
205
- $ envstack foo -r
266
+ $ ./foobar.env -r
206
267
  FOO=bar
207
268
  BAR=bar
208
269
  ```
209
270
 
210
- Variables can be platform specific (but always inherit from `all`):
271
+ #### More Details
272
+
273
+ Variables can be platform specific:
211
274
 
212
275
  ```yaml
276
+ darwin:
277
+ <<: *default
278
+ HELLO: olleh
213
279
  linux:
214
280
  <<: *default
215
281
  HELLO: world
216
-
217
282
  windows:
218
283
  <<: *default
219
284
  HELLO: goodbye
@@ -333,6 +398,16 @@ $ envstack -- echo {HELLO}
333
398
  world
334
399
  ```
335
400
 
401
+ Running a node command:
402
+
403
+ ```bash
404
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
405
+ $ node index.js
406
+ Hello undefined
407
+ $ envstack hello -- node index.js
408
+ Hello world
409
+ ```
410
+
336
411
  Running Python commands in the default stack:
337
412
 
338
413
  ```bash
@@ -365,7 +440,7 @@ environment stack that sets a value for `${PYEXE}`:
365
440
  #### hello.env
366
441
  ```yaml
367
442
  all: &default
368
- PYEXE: python
443
+ PYEXE: /usr/bin/python
369
444
  ```
370
445
 
371
446
  #### bin/hello
@@ -434,7 +509,7 @@ The following environment variables are used to help manage functionality:
434
509
  |------|-------------|
435
510
  | ENVPATH | Colon-separated paths to search for stack files |
436
511
  | IGNORE_MISSING | Ignore missing stack files when resolving environments |
437
- | STACK | Name of the current stack |
512
+ | STACK | Name of the current environment stack |
438
513
 
439
514
  # Tests
440
515
 
@@ -11,6 +11,7 @@ Environment variable management system.
11
11
  | Variable expansion modifiers | Supports bash-like variable expansion modifiers, allowing you to set default values for variables and override them in the environment or by higher scope stacks. |
12
12
  | Platform-specific variables | Stacks can have platform-specific variables and values. This allows you to define different values for variables based on the platform. |
13
13
  | Variable references | Variables can reference other variables, allowing for more flexibility and dynamic value assignment. |
14
+ | Multi-line values | Supports variables with multi-line values. |
14
15
  | Includes | Stack files can include other stacks, making it easy to reuse and combine different stacks. |
15
16
  | Python API | Provides a Python API that allows you to initialize and work with environment stacks programmatically. Easily initialize pre-defined environments with Python scripts, tools, and wrappers. |
16
17
  | Running commands | Allows you to run command line executables inside an environment stack, providing a convenient way to execute commands with a pre-defined environment. |
@@ -104,6 +105,43 @@ scope to lower scope, left to right):
104
105
  $ envstack [STACK [STACK ...]]
105
106
  ```
106
107
 
108
+ #### Executing Scripts
109
+
110
+ Environment stack files are also executable scripts that can be run directly:
111
+
112
+
113
+ ```bash
114
+ $ ./env/test.env
115
+ DEPLOY_ROOT=${ROOT}/${STACK}
116
+ ENV=${STACK}
117
+ ENVPATH=${DEPLOY_ROOT}/env:${ROOT}/prod/env
118
+ HELLO=${HELLO:=world}
119
+ LOG_LEVEL=DEBUG
120
+ PATH=${DEPLOY_ROOT}/bin:${ROOT}/prod/bin:${PATH}
121
+ PYTHONPATH=${DEPLOY_ROOT}/lib/python:${ROOT}/prod/lib/python:${PYTHONPATH}
122
+ ROOT=/mnt/pipe
123
+ STACK=test
124
+ ```
125
+
126
+ Run commands inside a specific environment stack file:
127
+
128
+ ```bash
129
+ $ ./env/test.env -- <command>
130
+ ```
131
+
132
+ For example:
133
+
134
+ ```bash
135
+ $ ./env/hello.env -- echo {HELLO}
136
+ world
137
+ ```
138
+
139
+ Export a specific environment stack file:
140
+
141
+ ```bash
142
+ $ ./env/hello.env --export
143
+ ```
144
+
107
145
  ## Setting Values
108
146
 
109
147
  Envstack uses bash-like variable expansion modifiers. Setting `$VAR` to a fixed
@@ -157,40 +195,67 @@ goodbye
157
195
  Several example or starter stacks are available in the [env folder of the
158
196
  envstack repo](https://github.com/rsgalloway/envstack/tree/master/env).
159
197
 
160
- To create a blank environment stack, create a new namespaced .env file and
161
- declare some variables.
198
+ To create a blank environment stack, create a new envstack file and declare some
199
+ variables.
162
200
 
163
- For example `foo.env` (the stack name is "foo"):
201
+ Create a new stack file called "foobar.env" and make it executable (note: at
202
+ least one VAR needs to be defined under all):
203
+
204
+ #### foobar.env
164
205
 
165
206
  ```yaml
207
+ #!/usr/bin/env envstack
208
+
166
209
  all: &default
167
210
  FOO: bar
168
211
  BAR: ${FOO}
212
+ darwin:
213
+ <<: *default
214
+ linux:
215
+ <<: *default
216
+ windows:
217
+ <<: *default
218
+ ```
219
+
220
+ Make it executable
221
+
222
+ ```bash
223
+ $ chmod +x ./foobar.env
169
224
  ```
170
225
 
171
- To see the resolved environment for the `foo` environment stack, run:
226
+ To see the resolved environment for the `foobar` stack, run:
172
227
 
173
228
  ```bash
174
- $ envstack foo
229
+ $ envstack foobar
175
230
  FOO=bar
176
231
  BAR=$FOO
177
232
  ```
178
233
 
234
+ or execute it directly:
235
+
236
+ ```bash
237
+ $ ./foobar.env
238
+ ```
239
+
179
240
  To see resolved values:
180
241
 
181
242
  ```bash
182
- $ envstack foo -r
243
+ $ ./foobar.env -r
183
244
  FOO=bar
184
245
  BAR=bar
185
246
  ```
186
247
 
187
- Variables can be platform specific (but always inherit from `all`):
248
+ #### More Details
249
+
250
+ Variables can be platform specific:
188
251
 
189
252
  ```yaml
253
+ darwin:
254
+ <<: *default
255
+ HELLO: olleh
190
256
  linux:
191
257
  <<: *default
192
258
  HELLO: world
193
-
194
259
  windows:
195
260
  <<: *default
196
261
  HELLO: goodbye
@@ -310,6 +375,16 @@ $ envstack -- echo {HELLO}
310
375
  world
311
376
  ```
312
377
 
378
+ Running a node command:
379
+
380
+ ```bash
381
+ $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
382
+ $ node index.js
383
+ Hello undefined
384
+ $ envstack hello -- node index.js
385
+ Hello world
386
+ ```
387
+
313
388
  Running Python commands in the default stack:
314
389
 
315
390
  ```bash
@@ -342,7 +417,7 @@ environment stack that sets a value for `${PYEXE}`:
342
417
  #### hello.env
343
418
  ```yaml
344
419
  all: &default
345
- PYEXE: python
420
+ PYEXE: /usr/bin/python
346
421
  ```
347
422
 
348
423
  #### bin/hello
@@ -411,7 +486,7 @@ The following environment variables are used to help manage functionality:
411
486
  |------|-------------|
412
487
  | ENVPATH | Colon-separated paths to search for stack files |
413
488
  | IGNORE_MISSING | Ignore missing stack files when resolving environments |
414
- | STACK | Name of the current stack |
489
+ | STACK | Name of the current environment stack |
415
490
 
416
491
  # Tests
417
492
 
@@ -34,6 +34,6 @@ Stacked environment variable management system.
34
34
  """
35
35
 
36
36
  __prog__ = "envstack"
37
- __version__ = "0.7.1"
37
+ __version__ = "0.7.3"
38
38
 
39
39
  from envstack.env import clear, init, revert, save
@@ -145,12 +145,11 @@ def main():
145
145
  if command:
146
146
  return run_command(command, args.namespace)
147
147
  elif args.resolve is not None:
148
- if len(args.resolve) == 0:
149
- args.resolve = load_environ(args.namespace).keys()
150
148
  resolved = resolve_environ(
151
149
  load_environ(args.namespace, platform=args.platform)
152
150
  )
153
- for key in sorted(args.resolve):
151
+ keys = args.resolve or resolved.keys()
152
+ for key in sorted(keys):
154
153
  val = resolved.get(key)
155
154
  print(f"{key}={val}")
156
155
  elif args.trace is not None:
@@ -160,8 +159,8 @@ def main():
160
159
  path = trace_var(*args.namespace, var=trace)
161
160
  print("{0}: {1}".format(trace, path))
162
161
  elif args.sources:
163
- sources = get_sources(*args.namespace, scope=args.scope)
164
- for source in sources:
162
+ env = load_environ(args.namespace, platform=args.platform)
163
+ for source in env.sources:
165
164
  print(source.path)
166
165
  elif args.clear:
167
166
  print(clear(args.namespace, config.SHELL))
@@ -169,7 +168,7 @@ def main():
169
168
  print(export(args.namespace, config.SHELL))
170
169
  else:
171
170
  env = load_environ(args.namespace, platform=args.platform)
172
- for k, v in sorted(env.items()):
171
+ for k, v in sorted(env.items(), key=lambda x: str(x[0])):
173
172
  print(f"{k}={v}")
174
173
 
175
174
  except KeyboardInterrupt: