summaryrefslogtreecommitdiff
path: root/python-cpenv.spec
blob: e28e0a2632f3edb30ff67db1424f66df54daa568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
%global _empty_manifest_terminate_build 0
Name:		python-cpenv
Version:	0.5.34
Release:	1
Summary:	Cross-platform module and environment management.
License:	MIT
URL:		https://pypi.org/project/cpenv/
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/28/67/c4825e79ddfb3cf6e1a66abab68ecebf85b501881f1e2d5bcd863422c398/cpenv-0.5.34.tar.gz
BuildArch:	noarch

Requires:	python3-tqdm
Requires:	python3-colorama
Requires:	python3-psutil

%description
<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/icon_dark.png"/>
</p>

# cpenv
Manage software plugins, project dependencies and environment
variables using Modules.

<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/demo.gif"/>
</p>

# Installation
The recommended method of installing cpenv is via [pipx](https://pipxproject.github.io/pipx).
Pipx is used to install python cli applications in isolation.

```
pipx install cpenv
```
```
pipx upgrade cpenv
```
```
pipx uninstall cpenv
```

# Overview
Cpenv is a cli tool and python library used to create, edit, publish, and activate Modules. A Module is a folder containing a dependency, like Arnold for Maya, and a module file that configures it.

## Environment Variables
| Variable                 | Description                            | Default |
| ------------------------ | -------------------------------------- | ------- |
| CPENV_HOME               | Customize path to cpenv home           |         |
| CPENV_DISABLE_PROMPT     | Disable prompt when modules activated  | 0       |
| CPENV_ACTIVE_MODULES     | List of activated modules              |         |
| CPENV_SHELL              | Preferred subshell like "powershell"   |         |

## Example Modules
- [snack](https://github.com/cpenv/snack)

## Create a Module
Use `cpenv create <module>` to use a guide to create a new Module.
This will create a new folder in your current working directory with a module file in it.

## Edit a Module
Each Module contains a module.yml file, referred to as a module file. A module file contains metadata like the name and version of a module, as well as configuration, like environment variables.
```
# Variables
# $MODULE - path to this module
# $PLATFORM - platform name (win, mac, linux)
# $PYVER - python version (2.7, 3.6...)

# Wrap variables in brackets when they are nested within a string.
#     DO 'this${variable}isnested/' NOT 'this$variableisnested'

name: 'my_module'
version: '0.1.0'
description: 'My first module.'
author: 'Me'
email: 'me@email.com'
requires: []
environment:
    MY_MODULE_VAR: 'Test'
```

### Environment key
Setting a value will insert a key or overwrite it's existing value.
```
SOME_VAR: 'SOME_VALUE'
```

Use the $MODULE variable for module relative paths.
```
RELATIVE_VAR: $MODULE/bin
```

Use lists to prepend values to a key.
```
PATH:
    - $MODULE/bin
```

Use `win`, `linux` and `mac or osx` keys to declare platform specific values. If you leave out a platform, the variable will not be included on that platform.
```
PLATFORM_VAR:
    mac: /mnt/some/path
    linux: /Volumes/some/path
    win: C:/some/path
```

You can also use platform keys when prepending values to a variable.
```
PATH:
    - mac: $MODULE/macattack
      linux: $MODULE/penguin
      win: $MODULE/squares
```

Reuse environment variables to simplify things.
```
BASE: $MODULE/$PLATFORM/base
PATH:
    - $BASE/bin
PYTHONPATH:
    - $BASE/python
```

#### Advanced
The implicit set and prepend operations above cover the most common use cases when modifying environment variables. For more advanced use cases you can use the following explicit operation keys.
```
SVAR:
    set:
        - Value0
        - Value1
PVAR:
    prepend:
        - X
RVAR:
    unset: 1
PATH:
    remove:
        - C:/Python27
        - C:/Python27/Scripts
PYTHONPATH:
    append:
        - $MODULE/python
        - $MODULE/lib
```

You can also uses lists of opreations to perform complex modifications.
```
PATH:
    - remove: /some/file/path
    - append: /some/other/path
    - prepend: /one/more/path
```

One workflow that this enables is the use of modules solely for the purpose of overriding environment variables. Imagine you have a module `my_tool` and it uses a variable `MY_TOOL_PLUGINS` to lookup plugins.
```
name: my_tool
...
environment:
    MY_TOOL_PLUGINS:
        - //studio/dev/my_tool/plugins
        - //studio/projects/test_project/plugins
```

Now imagine you have a new project and you want `my_tool` to look at a different location for plugins just for that project. Rather than create a new version of the `my_tool` module, create a override module. We might name this module after our project, `project_b`.
```
name: project_b
...
environment:
    MY_TOOL_PLUGINS:
        set:
            - //studio/prod/my_tool/plugins
            - //studio/projects/project_b/plugins
```

All we have to do is activate `my_tool` and `project_b` in that order to make sure our overrides are used.
```
> cpenv activate my_tool project_b
```

#### Requires key
The requires key is a list of dependencies that a module needs to function. Currently this is only used for reference, these modules will not be activated automatically.

## Test a Module
When you're working on a module navigate into it's root directory. Then you can activate it using `cpenv activate .`. This is
the best way to validate your module prior to publishing.

## Publish a Module
Once you're Module is ready for production, use `cpenv publish .` to publish it. Publishing a Module uploads it to a Repo of your choosing.

# Repos
Repos are storage locations for Modules that support finding, listing, uploading, and downloading Modules via *requirements* like
`my_module-0.1.0`. Cpenv is configured with the following LocalRepos by default:

- **cwd** - Your current working directory
- **user** - A user specific repo
- **home** - A machine wide repo

Use `cpenv repo list` to display your configured Repos. LocalRepos point directly to folders on your local file system.
Customize the home Repo by setting the `CPENV_HOME` environment variable.

When you activate a module using a requirement, all configured Repos are searched and the best match is used. If the resolved
module is not in a LocalRepo it will be downloaded to your home Repo then activated. This is one of the key features of cpenv
and allows for strong distributed workflows. For example, you can configure a remote repo like the ShotgunRepo and store your modules directly in a
[Shotgun studio](https://www.shotgunsoftware.com/) database. [Visit the tk-cpenv repository for more info on using cpenv with Shotgun](https://github.com/cpenv/tk-cpenv)

# Requirements
Requirements are strings used to resolve and activate modules in Repos. They can be versionless like `my_module` or require a
version like `my_module-0.1.0`. Cpenv supports semver/calver, simple versions (v1), and what I like to call *weird* versions
like 12.0v2 (The Foundry products). In the future cpenv may support more complex requirements by utilizing
[resolvelib](https://github.com/sarugaku/resolvelib).


%package -n python3-cpenv
Summary:	Cross-platform module and environment management.
Provides:	python-cpenv
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-cpenv
<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/icon_dark.png"/>
</p>

# cpenv
Manage software plugins, project dependencies and environment
variables using Modules.

<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/demo.gif"/>
</p>

# Installation
The recommended method of installing cpenv is via [pipx](https://pipxproject.github.io/pipx).
Pipx is used to install python cli applications in isolation.

```
pipx install cpenv
```
```
pipx upgrade cpenv
```
```
pipx uninstall cpenv
```

# Overview
Cpenv is a cli tool and python library used to create, edit, publish, and activate Modules. A Module is a folder containing a dependency, like Arnold for Maya, and a module file that configures it.

## Environment Variables
| Variable                 | Description                            | Default |
| ------------------------ | -------------------------------------- | ------- |
| CPENV_HOME               | Customize path to cpenv home           |         |
| CPENV_DISABLE_PROMPT     | Disable prompt when modules activated  | 0       |
| CPENV_ACTIVE_MODULES     | List of activated modules              |         |
| CPENV_SHELL              | Preferred subshell like "powershell"   |         |

## Example Modules
- [snack](https://github.com/cpenv/snack)

## Create a Module
Use `cpenv create <module>` to use a guide to create a new Module.
This will create a new folder in your current working directory with a module file in it.

## Edit a Module
Each Module contains a module.yml file, referred to as a module file. A module file contains metadata like the name and version of a module, as well as configuration, like environment variables.
```
# Variables
# $MODULE - path to this module
# $PLATFORM - platform name (win, mac, linux)
# $PYVER - python version (2.7, 3.6...)

# Wrap variables in brackets when they are nested within a string.
#     DO 'this${variable}isnested/' NOT 'this$variableisnested'

name: 'my_module'
version: '0.1.0'
description: 'My first module.'
author: 'Me'
email: 'me@email.com'
requires: []
environment:
    MY_MODULE_VAR: 'Test'
```

### Environment key
Setting a value will insert a key or overwrite it's existing value.
```
SOME_VAR: 'SOME_VALUE'
```

Use the $MODULE variable for module relative paths.
```
RELATIVE_VAR: $MODULE/bin
```

Use lists to prepend values to a key.
```
PATH:
    - $MODULE/bin
```

Use `win`, `linux` and `mac or osx` keys to declare platform specific values. If you leave out a platform, the variable will not be included on that platform.
```
PLATFORM_VAR:
    mac: /mnt/some/path
    linux: /Volumes/some/path
    win: C:/some/path
```

You can also use platform keys when prepending values to a variable.
```
PATH:
    - mac: $MODULE/macattack
      linux: $MODULE/penguin
      win: $MODULE/squares
```

Reuse environment variables to simplify things.
```
BASE: $MODULE/$PLATFORM/base
PATH:
    - $BASE/bin
PYTHONPATH:
    - $BASE/python
```

#### Advanced
The implicit set and prepend operations above cover the most common use cases when modifying environment variables. For more advanced use cases you can use the following explicit operation keys.
```
SVAR:
    set:
        - Value0
        - Value1
PVAR:
    prepend:
        - X
RVAR:
    unset: 1
PATH:
    remove:
        - C:/Python27
        - C:/Python27/Scripts
PYTHONPATH:
    append:
        - $MODULE/python
        - $MODULE/lib
```

You can also uses lists of opreations to perform complex modifications.
```
PATH:
    - remove: /some/file/path
    - append: /some/other/path
    - prepend: /one/more/path
```

One workflow that this enables is the use of modules solely for the purpose of overriding environment variables. Imagine you have a module `my_tool` and it uses a variable `MY_TOOL_PLUGINS` to lookup plugins.
```
name: my_tool
...
environment:
    MY_TOOL_PLUGINS:
        - //studio/dev/my_tool/plugins
        - //studio/projects/test_project/plugins
```

Now imagine you have a new project and you want `my_tool` to look at a different location for plugins just for that project. Rather than create a new version of the `my_tool` module, create a override module. We might name this module after our project, `project_b`.
```
name: project_b
...
environment:
    MY_TOOL_PLUGINS:
        set:
            - //studio/prod/my_tool/plugins
            - //studio/projects/project_b/plugins
```

All we have to do is activate `my_tool` and `project_b` in that order to make sure our overrides are used.
```
> cpenv activate my_tool project_b
```

#### Requires key
The requires key is a list of dependencies that a module needs to function. Currently this is only used for reference, these modules will not be activated automatically.

## Test a Module
When you're working on a module navigate into it's root directory. Then you can activate it using `cpenv activate .`. This is
the best way to validate your module prior to publishing.

## Publish a Module
Once you're Module is ready for production, use `cpenv publish .` to publish it. Publishing a Module uploads it to a Repo of your choosing.

# Repos
Repos are storage locations for Modules that support finding, listing, uploading, and downloading Modules via *requirements* like
`my_module-0.1.0`. Cpenv is configured with the following LocalRepos by default:

- **cwd** - Your current working directory
- **user** - A user specific repo
- **home** - A machine wide repo

Use `cpenv repo list` to display your configured Repos. LocalRepos point directly to folders on your local file system.
Customize the home Repo by setting the `CPENV_HOME` environment variable.

When you activate a module using a requirement, all configured Repos are searched and the best match is used. If the resolved
module is not in a LocalRepo it will be downloaded to your home Repo then activated. This is one of the key features of cpenv
and allows for strong distributed workflows. For example, you can configure a remote repo like the ShotgunRepo and store your modules directly in a
[Shotgun studio](https://www.shotgunsoftware.com/) database. [Visit the tk-cpenv repository for more info on using cpenv with Shotgun](https://github.com/cpenv/tk-cpenv)

# Requirements
Requirements are strings used to resolve and activate modules in Repos. They can be versionless like `my_module` or require a
version like `my_module-0.1.0`. Cpenv supports semver/calver, simple versions (v1), and what I like to call *weird* versions
like 12.0v2 (The Foundry products). In the future cpenv may support more complex requirements by utilizing
[resolvelib](https://github.com/sarugaku/resolvelib).


%package help
Summary:	Development documents and examples for cpenv
Provides:	python3-cpenv-doc
%description help
<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/icon_dark.png"/>
</p>

# cpenv
Manage software plugins, project dependencies and environment
variables using Modules.

<p align="center">
    <img src="https://raw.github.com/cpenv/cpenv/master/res/demo.gif"/>
</p>

# Installation
The recommended method of installing cpenv is via [pipx](https://pipxproject.github.io/pipx).
Pipx is used to install python cli applications in isolation.

```
pipx install cpenv
```
```
pipx upgrade cpenv
```
```
pipx uninstall cpenv
```

# Overview
Cpenv is a cli tool and python library used to create, edit, publish, and activate Modules. A Module is a folder containing a dependency, like Arnold for Maya, and a module file that configures it.

## Environment Variables
| Variable                 | Description                            | Default |
| ------------------------ | -------------------------------------- | ------- |
| CPENV_HOME               | Customize path to cpenv home           |         |
| CPENV_DISABLE_PROMPT     | Disable prompt when modules activated  | 0       |
| CPENV_ACTIVE_MODULES     | List of activated modules              |         |
| CPENV_SHELL              | Preferred subshell like "powershell"   |         |

## Example Modules
- [snack](https://github.com/cpenv/snack)

## Create a Module
Use `cpenv create <module>` to use a guide to create a new Module.
This will create a new folder in your current working directory with a module file in it.

## Edit a Module
Each Module contains a module.yml file, referred to as a module file. A module file contains metadata like the name and version of a module, as well as configuration, like environment variables.
```
# Variables
# $MODULE - path to this module
# $PLATFORM - platform name (win, mac, linux)
# $PYVER - python version (2.7, 3.6...)

# Wrap variables in brackets when they are nested within a string.
#     DO 'this${variable}isnested/' NOT 'this$variableisnested'

name: 'my_module'
version: '0.1.0'
description: 'My first module.'
author: 'Me'
email: 'me@email.com'
requires: []
environment:
    MY_MODULE_VAR: 'Test'
```

### Environment key
Setting a value will insert a key or overwrite it's existing value.
```
SOME_VAR: 'SOME_VALUE'
```

Use the $MODULE variable for module relative paths.
```
RELATIVE_VAR: $MODULE/bin
```

Use lists to prepend values to a key.
```
PATH:
    - $MODULE/bin
```

Use `win`, `linux` and `mac or osx` keys to declare platform specific values. If you leave out a platform, the variable will not be included on that platform.
```
PLATFORM_VAR:
    mac: /mnt/some/path
    linux: /Volumes/some/path
    win: C:/some/path
```

You can also use platform keys when prepending values to a variable.
```
PATH:
    - mac: $MODULE/macattack
      linux: $MODULE/penguin
      win: $MODULE/squares
```

Reuse environment variables to simplify things.
```
BASE: $MODULE/$PLATFORM/base
PATH:
    - $BASE/bin
PYTHONPATH:
    - $BASE/python
```

#### Advanced
The implicit set and prepend operations above cover the most common use cases when modifying environment variables. For more advanced use cases you can use the following explicit operation keys.
```
SVAR:
    set:
        - Value0
        - Value1
PVAR:
    prepend:
        - X
RVAR:
    unset: 1
PATH:
    remove:
        - C:/Python27
        - C:/Python27/Scripts
PYTHONPATH:
    append:
        - $MODULE/python
        - $MODULE/lib
```

You can also uses lists of opreations to perform complex modifications.
```
PATH:
    - remove: /some/file/path
    - append: /some/other/path
    - prepend: /one/more/path
```

One workflow that this enables is the use of modules solely for the purpose of overriding environment variables. Imagine you have a module `my_tool` and it uses a variable `MY_TOOL_PLUGINS` to lookup plugins.
```
name: my_tool
...
environment:
    MY_TOOL_PLUGINS:
        - //studio/dev/my_tool/plugins
        - //studio/projects/test_project/plugins
```

Now imagine you have a new project and you want `my_tool` to look at a different location for plugins just for that project. Rather than create a new version of the `my_tool` module, create a override module. We might name this module after our project, `project_b`.
```
name: project_b
...
environment:
    MY_TOOL_PLUGINS:
        set:
            - //studio/prod/my_tool/plugins
            - //studio/projects/project_b/plugins
```

All we have to do is activate `my_tool` and `project_b` in that order to make sure our overrides are used.
```
> cpenv activate my_tool project_b
```

#### Requires key
The requires key is a list of dependencies that a module needs to function. Currently this is only used for reference, these modules will not be activated automatically.

## Test a Module
When you're working on a module navigate into it's root directory. Then you can activate it using `cpenv activate .`. This is
the best way to validate your module prior to publishing.

## Publish a Module
Once you're Module is ready for production, use `cpenv publish .` to publish it. Publishing a Module uploads it to a Repo of your choosing.

# Repos
Repos are storage locations for Modules that support finding, listing, uploading, and downloading Modules via *requirements* like
`my_module-0.1.0`. Cpenv is configured with the following LocalRepos by default:

- **cwd** - Your current working directory
- **user** - A user specific repo
- **home** - A machine wide repo

Use `cpenv repo list` to display your configured Repos. LocalRepos point directly to folders on your local file system.
Customize the home Repo by setting the `CPENV_HOME` environment variable.

When you activate a module using a requirement, all configured Repos are searched and the best match is used. If the resolved
module is not in a LocalRepo it will be downloaded to your home Repo then activated. This is one of the key features of cpenv
and allows for strong distributed workflows. For example, you can configure a remote repo like the ShotgunRepo and store your modules directly in a
[Shotgun studio](https://www.shotgunsoftware.com/) database. [Visit the tk-cpenv repository for more info on using cpenv with Shotgun](https://github.com/cpenv/tk-cpenv)

# Requirements
Requirements are strings used to resolve and activate modules in Repos. They can be versionless like `my_module` or require a
version like `my_module-0.1.0`. Cpenv supports semver/calver, simple versions (v1), and what I like to call *weird* versions
like 12.0v2 (The Foundry products). In the future cpenv may support more complex requirements by utilizing
[resolvelib](https://github.com/sarugaku/resolvelib).


%prep
%autosetup -n cpenv-0.5.34

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-cpenv -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue May 30 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.34-1
- Package Spec generated