summaryrefslogtreecommitdiff
path: root/python-ebbs.spec
blob: fde084032a1aa8d31ea06f40f77ec82766e13934 (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
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
%global _empty_manifest_terminate_build 0
Name:		python-ebbs
Version:	2.2.21
Release:	1
Summary:	eons Basic Build System
License:	MIT License
URL:		https://github.com/eons-dev/ebbs.exe
Source0:	https://mirrors.aliyun.com/pypi/web/packages/45/dc/d7dd9b6380bf947403e1957d49b3f1e72422ac9a95023896c7666394bd9c/ebbs-2.2.21.tar.gz
BuildArch:	noarch

Requires:	python3-eons
Requires:	python3-jsonpickle

%description
# Eons Basic Build System

EBBS (or ebbs) is a framework for designing modular build pipelines for any language and system. Builders are python scripts that are downloaded and run on the fly with configuration provided by json config files, environment variables, and command line arguments!

Here, at eons, we have found building and distributing code to be too hard and far too disparate between languages. Thus, we designed ebbs to make packaging and distributing code consistent. No matter what language you're working with and no matter what you want to do with your code.

Want to compile C++ in a containerized environment then publish that code as an image back to Docker? How about publish your python code to PyPI or even just build a simple Wordpress plugin? No matter how intricate or big your project becomes, you'll be able to rely on ebbs to automate every step of your build process. It's just python. That's literally it.

With ebbs, there will be no more:
 * having to learn a new way to package code for every language.
 * having to change your code to fit your build system.
 * having to specify unnecessary configuration for every project.

Instead, you write your code the way you want and your ebbs build system will put the pieces together for you.
Ebbs has been written in adherence to the [eons naming conventions](https://eons.llc/convention/naming/) and [eons directory conventions](https://eons.llc/convention/uri-names/). However, we do try to make overriding these conventions as easy as possible so that you don't have to change your existing code to use our systems.

 For example, if you use "include" instead of the eons-preferred "inc", you can tell ebbs:
```json
"copy" : [
  {"../include" : "inc"}
]
```
In the same fashion, you can bypass the eons directory scheme ("my_project.exe", "my_project.lib", "my_project.img", etc.) by specifying `"name" : "my_project"` and `"type" : "exe"` or whatever you'd like.

If you find ebbs to be getting in the way or overly challenging, let us know! Seriously, building code should be easy and we're always happy to know how we can improve. Feel free to open issues or just email us at support@eons.llc.

## Installation
`pip install ebbs`

## Usage

Ebbs must be invoked from the directory you wish to build from.
For example, a well-designed project should allow you compile it locally by:
```shell
cd build
ebbs
```

Per (eons)[https://github.com/eons-dev/eons.lib], ebbs supports:
* `-v` or `--verbose` (count, i.e `-vv` = 2) or `--verbosity #`, where # is some number, or the `verbosity` environment or config value: will show more information and increase the logging level, e.g. print debug messages (3 for debug; 2 for info).
* `--config` or `-c` (string): the path to a json config file from which other values may be retrieved.
* `--no-repo` or the `no_repo` environment or config value (bool, i.e. 'True', 'true', etc.): whether or not to enable reaching out to online servers for code (see Dynamic Functionality, below).
* `--log-file` or the `log_file` environment or config value (string; supports formatting, e.g. '/var/log/eons/{this.name}.log'): optional value for logging to a file in addition to stderr.

As always, use `ebbs --help` for help ;)

### Configuration

Ebbs is intended to keep your build process separate from your code. With that said, it can be useful to specify some project-wide settings and build configurations.
Note that there isn't any real reason you can't move the build.json or even write an ebbs script to generate build.json and then call ebbs with it ;)

When running ebbs, the builder you select will pull its configuration values from the following external sources:
 1. the command line (e.g. in case you want to override anything)
 2. a "build.json" in the provided build folder (which can be specified via `--config`)
 3. a json file provided to `ebbs`.
 4. the system environment (e.g. for keeping passwords out of repo-files and commands)
Any existing member variables will override these external values.

You can manually specify the builder you'd like in one of 2 ways:
 1. the `-b` argument to ebbs.
 2. `"build" : "SOMETHING"` in the build.json

Lastly, you can specify a build folder (i.e. a folder to create within your project for all build output) with:
 1. `-i` on the cli; the default is "build" (e.g. "/path/to/my/project/build")
 2. `"build_in" : "BUILD_FOLDER"` in the build.json

You can also specify any number of other arguments in any of the command line, build.json, and system environments.
For example, `export pypi_username="__token__"` would make `this.Fetch('pypi_username)` in the "py" Builder return `__token__`, assuming you don't set `"pypi_username" : "something else"` in the build.json nor specify `--pypi-username "something else"` on the command line.

**IMPORTANT NOTE: Most ebbs Builders will DELETE the build folder you pass to them.**

This is done so that previous builds cannot create stale data which influence future builds. However, if you mess up and call, say, `ebbs -b cpp` from `./src` instead of from `./build`, you could lose your "src" folder. Please use this tool responsibly and read up on what each Builder does.
To make things easy, you can search for `clearBuildPath` in the python file and `clear_build_path` in the config files. If you see `this.clearBuildPath = False` it should be okay to use that Builder with any directory (such is the case for the Publish Builder, which zips the contents of any directory and uploads them to an online repository). Conversely, take note of where `"clear_build_path": true` is set.

### Where Are These "Builders"?

All Builders are searched for in the local file system from where ebbs was called within the following folders:
```python
"./eons" #per the eons.Executor.defaultRepoDirectory
```

If the build you specified is not found within one of those directories, ebbs will try to download it from the remote repository with a name of `{builder}.build`. The downloaded build script will be saved to whatever directory you set in `--repo-store` (default "./eons/").

Unfortunately, python class names cannot have dashes ("-") in them. Instead, a series of underscores (`_`) is often used instead. While this deviates from the eons naming schema, it should still be intelligible for short names. You are, of course, welcome to use whatever naming scheme you would like instead!

### The Build Path

As mentioned, ebbs depends on the directory it is invoked from. The `rootPath` provided to each Builder will be this directory. The `buildPath` is specified relative to the `rootPath`. If you would like to use a single folder for all Builders, please set the `repo_store` environment variable with an absolute path.

For example, if you have a "git" and a "workspace" folder in your home directory and you want to use your custom Builder, "my_build" on all the projects in the git folder, instead of copying my_build to every project's workspace, you could simply `export repo_store="~/workspace"` and call ebbs from the appropriate build directory for each project.
Something like: `me@mine:~/git/my_cpp_project.exe/build$ ebbs -b my_build`. NOTE: if the build.json file `~/git/my_cpp_project.exe/build/build.json` exists, it will affect the behavior of `my_build` and potentially even effect other Builders. To ensure no side-effects are generated from project build configurations, you should create an empty folder to invoke your custom build process from (e.g `local/`).

Your home folder would then look something like:
```
home/
├─ git/
│  ├─ my_cpp_project.exe/
├─ workspace/
│  ├─ my_build.py
```

### Repository

Online repository settings can be specified with:
```
--repo-store (default = ./eons/)
--repo-url (default = https://api.infrastructure.tech/v1/package)
--repo-username
--repo-password
```

NOTE: you do not need to supply any repo credentials or other settings in order to download packages from the public repository.

For more info on the repo integration, see [the eons library](https://github.com/eons-dev/lib_eons#online-repository)

It is also worth noting that the online repository system is handled upstream (and downstream, for Publish) of ebbs.

By default, ebbs will use the [infrastructure.tech](https://infrastructure.tech) package repository. See the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv) for more info.

**IMPORTANT CAVEAT FOR ONLINE PACKAGES:** the package name must be suffixed with the "build" extension to be found by ebbs.  
For example, if you want to use `-b my_build` from the repository, ebbs will attempt to download "my_build.build". The package zip (my_build.build.zip) is then downloaded, extracted, registered, and instantiated.  
All packages are .zip files.

### Example Build Scripts:

* [Python](https://github.com/eons-dev/py.build)
* [C++](https://github.com/eons-dev/cpp.build)
* [Docker](https://github.com/eons-dev/docker.build)
* [Publish](https://github.com/eons-dev/publish.build) <- this one makes other Builders available online.
* [In Container](https://github.com/eons-dev/in_container.build) <- this one moves the remaining build process into a docker container.
* [Arbitrary](https://github.com/eons-dev/arbitrary.build) <- this one just runs commands.
* [Proxy](https://github.com/eons-dev/proxy.build) <- this one loads another json config file.
* [Test](https://github.com/eons-dev/test.build) <- this one runs commands and validates the outputs.

### Cascading Builds

As with any good build system, you aren't limited to just one step or even one file. With ebbs, you can specify "next" in your build.json (see below), which will execute a series of Builders after the initial.

Here's an example build.json that builds a C++ project then pushes it to Dockerhub (taken from the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv)):
```json
{
  "clear_build_path" : true,
  "next": [
	{
	  "build" : "in_container",
	  "config" : {
		"image" : "eons/dev-webserver.img",
		"copy_env" : [
		  "docker_username",
		  "docker_password"
		],
		"next" : [
		  {
			"build" : "cpp",
			"build_in" : "build",
			"copy" : [
			  {"../../inc/" : "inc/"},
			  {"../../src/" : "src/"}
			],
	        "config" : {
              "file_name" : "entrypoint",
              "cpp_version" : 17,
              "libs_shared": [
                "restbed",
                "cpr"
              ],
              "next" : [
                {
                  "build": "docker",
                  "path" : "infrastructure.srv",
                  "copy" : [
                    {"out/" : "src/"}
                  ],
                  "config" : {
                    "base_image" : "eons/webserver.img",
                    "image_name" : "eons/infrastructure.srv",
                    "image_os" : "debian",
                    "entrypoint" : "/usr/local/bin/entrypoint",
                    "also" : [
                      "EXPOSE 80"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
```
This script can be invoked with just `ebbs` (assuming the appropriate docker credentials are stored in your environment, docker is installed, etc.).

For other examples, check out the `build` folder of this repo and any other mentioned above!

## Design

### I Want One!

Before diving too deep into EBBS, please also give a quick look at the parent library: [eons](https://github.com/eons-dev/eons.lib).
The [UserFunctor Utilities](https://github.com/eons-dev/eons.lib#user-functor) will be of particular use in your Builders.

Ebbs builds packages or whatever with `ebbs.Builders`, which extend the self-registering `eons.UserFunctor`. This means you can write your own build scripts and publish them, distribute them with your code, or store them locally in the `repo_store` (see above). A major driving force behind ebbs is to encourage you to share your automation tools with colleagues, friends, and enemies! For example, you could create "my_build.py", containing something like:
```python
import logging
from ebbs import Builder

class my_build(Builder):
    def __init__(this, name="My Build"):
        super().__init__(name)
        
        # delete whatever dir was provided to this, so we can start fresh.
        this.clearBuildPath = True
        
        this.supportedProjectTypes = [] #all
        #or
        # this.supportedProjectTypes.append("lib")
        # this.supportedProjectTypes.append("exe")
        # this.supportedProjectTypes.append("test")
        
        #this.requiredKWArgs will cause an error to be thrown prior to execution (i.e. .*Build methods) iff they are not found in the system environment, build.json, nor command line.
        this.requiredKWArgs.append("my_required_arg")
        
        #this.my_optional_arg will be "some default value" unless the user overrides it from the command line or build.json file.
        this.optionalKWArgs["my_optional_arg"] = "some default value"
        
    #Check if the output of all your this.RunCommand() and whatever other calls did what you expected.
    #The "next" step will only be executed if this step succeeded.
    def DidBuildSucceed(this):
        return True; #yeah, why not?

    def PreBuild(this):
        logging.info(f"Got {this.my_required_arg} and {this.my_optional_arg}")
        
    #Required Builder method. See that class for details.
    def Build(this):
        #DO STUFF!
```
That file can then go in a "./ebbs/" or "./eons/" directory, perhaps within your project repository or on [infrastructure.tech](https://infrastructure.tech)!
ebbs can then be invoked with something like: `ebbs -b my_build --my-required-arg my-value`, which will run your Builder in the current path!

Also note the "--" preceding "--my-required-arg", which evaluates to "my_required_arg" (without the "--" and with "_" in place of "-") once in the Builder. This is done for convenience of both command line syntax and python code.

You could also do something like:
```shell
cat << EOF > ./build.json
{
  "my_required_arg" : "my-value",
  "my_optional_arg" : [
    "some",
    "other",
    "value",
    "that",
    "you",
    "don't",
    "want",
    "to",
    "type"
  ]
}
EOF

ebbs -b my_build
```
Here, the build.json file will be automatically read in, removing the need to specify the args for your build.

If you'd like to take this a step further, you can remove the need for `-b my_build` by specifying it under an empty builder in the build.json, like so:

```shell
cat << EOF > ./build.json
{
  "next": [
    {
      "build" : "my_build",
      "build_in" : "build",
      "copy" : [
        {"../src/" : "src/"},
        {"../inc/" : "inc/"},
        {"../test/" : "test/"}
      ],
      "config" : {
        "my_required_arg" : "my-value",
        "my_optional_arg" : [
          "some",
          "other",
          "value",
          "that",
          "you",
          "don't",
          "want",
          "to",
          "type"
        ]
      }
    }
  ]
}
EOF

ebbs #no args needed!
```

Regarding `this.clearBuildPath`, as mentioned above, it is important to not call ebbs on the wrong directory. If your Builder does not need a fresh build path, set `this.clearBuildPath = False`.
With that said, most compilation, packaging, etc. can be broken by stale data from past builds, so make sure to set `this.clearBuildPath = True` if you need to.

You may also have noticed the combination of camelCase and snake_case. This is used to specify builtInValues from user_provided_values. This convention may change with a future release (let us know what you think!).

For `supportedProjectTypes`, the `Builder` class will split the folder containing the buildPath (i.e. the `rootPath`) on underscores (`_`), storing the first value as `this.projectType` and the second as `this.projectName`. The `projectType` is checked against the used build's `supportedProjectTypes`. If no match is found, the build is aborted prior to executing the build. If you would like your Builder to work with all project types (and thus ignore that whole naming nonsense), set `this.supportedProjectTypes = []`, where none (i.e. `[]`, not actually `None`) means "all".


You'll also get the following paths variables populated by default:
```python
this.srcPath = f"{this.rootPath}/src"
this.incPath = f"{this.rootPath}/inc"
this.depPath = f"{this.rootPath}/dep"
this.libPath = f"{this.rootPath}/lib"
this.exePath = f"{this.rootPath}/exe"
this.testPath = f"{this.rootPath}/test"
```

When a `Builder` is executed, the following are called in order:  
(kwargs is the same for all)
```python
this.ValidateArgs() # <- not recommended to override.
this.BeforeFunction() # <- virtual (ok to override)
#Builder sets the above mentioned variables here
this.PreBuild() # <- virtual (ok to override)
#Supported project types are checked here
this.Build() # <- abstract method for you  (MUST override)
this.PostBuild() # <- virtual (ok to override)
if (this.DidBuildSucceed()):
    this.BuildNext()
this.AfterFunction() # <- virtual (ok to override)
```


%package -n python3-ebbs
Summary:	eons Basic Build System
Provides:	python-ebbs
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-ebbs
# Eons Basic Build System

EBBS (or ebbs) is a framework for designing modular build pipelines for any language and system. Builders are python scripts that are downloaded and run on the fly with configuration provided by json config files, environment variables, and command line arguments!

Here, at eons, we have found building and distributing code to be too hard and far too disparate between languages. Thus, we designed ebbs to make packaging and distributing code consistent. No matter what language you're working with and no matter what you want to do with your code.

Want to compile C++ in a containerized environment then publish that code as an image back to Docker? How about publish your python code to PyPI or even just build a simple Wordpress plugin? No matter how intricate or big your project becomes, you'll be able to rely on ebbs to automate every step of your build process. It's just python. That's literally it.

With ebbs, there will be no more:
 * having to learn a new way to package code for every language.
 * having to change your code to fit your build system.
 * having to specify unnecessary configuration for every project.

Instead, you write your code the way you want and your ebbs build system will put the pieces together for you.
Ebbs has been written in adherence to the [eons naming conventions](https://eons.llc/convention/naming/) and [eons directory conventions](https://eons.llc/convention/uri-names/). However, we do try to make overriding these conventions as easy as possible so that you don't have to change your existing code to use our systems.

 For example, if you use "include" instead of the eons-preferred "inc", you can tell ebbs:
```json
"copy" : [
  {"../include" : "inc"}
]
```
In the same fashion, you can bypass the eons directory scheme ("my_project.exe", "my_project.lib", "my_project.img", etc.) by specifying `"name" : "my_project"` and `"type" : "exe"` or whatever you'd like.

If you find ebbs to be getting in the way or overly challenging, let us know! Seriously, building code should be easy and we're always happy to know how we can improve. Feel free to open issues or just email us at support@eons.llc.

## Installation
`pip install ebbs`

## Usage

Ebbs must be invoked from the directory you wish to build from.
For example, a well-designed project should allow you compile it locally by:
```shell
cd build
ebbs
```

Per (eons)[https://github.com/eons-dev/eons.lib], ebbs supports:
* `-v` or `--verbose` (count, i.e `-vv` = 2) or `--verbosity #`, where # is some number, or the `verbosity` environment or config value: will show more information and increase the logging level, e.g. print debug messages (3 for debug; 2 for info).
* `--config` or `-c` (string): the path to a json config file from which other values may be retrieved.
* `--no-repo` or the `no_repo` environment or config value (bool, i.e. 'True', 'true', etc.): whether or not to enable reaching out to online servers for code (see Dynamic Functionality, below).
* `--log-file` or the `log_file` environment or config value (string; supports formatting, e.g. '/var/log/eons/{this.name}.log'): optional value for logging to a file in addition to stderr.

As always, use `ebbs --help` for help ;)

### Configuration

Ebbs is intended to keep your build process separate from your code. With that said, it can be useful to specify some project-wide settings and build configurations.
Note that there isn't any real reason you can't move the build.json or even write an ebbs script to generate build.json and then call ebbs with it ;)

When running ebbs, the builder you select will pull its configuration values from the following external sources:
 1. the command line (e.g. in case you want to override anything)
 2. a "build.json" in the provided build folder (which can be specified via `--config`)
 3. a json file provided to `ebbs`.
 4. the system environment (e.g. for keeping passwords out of repo-files and commands)
Any existing member variables will override these external values.

You can manually specify the builder you'd like in one of 2 ways:
 1. the `-b` argument to ebbs.
 2. `"build" : "SOMETHING"` in the build.json

Lastly, you can specify a build folder (i.e. a folder to create within your project for all build output) with:
 1. `-i` on the cli; the default is "build" (e.g. "/path/to/my/project/build")
 2. `"build_in" : "BUILD_FOLDER"` in the build.json

You can also specify any number of other arguments in any of the command line, build.json, and system environments.
For example, `export pypi_username="__token__"` would make `this.Fetch('pypi_username)` in the "py" Builder return `__token__`, assuming you don't set `"pypi_username" : "something else"` in the build.json nor specify `--pypi-username "something else"` on the command line.

**IMPORTANT NOTE: Most ebbs Builders will DELETE the build folder you pass to them.**

This is done so that previous builds cannot create stale data which influence future builds. However, if you mess up and call, say, `ebbs -b cpp` from `./src` instead of from `./build`, you could lose your "src" folder. Please use this tool responsibly and read up on what each Builder does.
To make things easy, you can search for `clearBuildPath` in the python file and `clear_build_path` in the config files. If you see `this.clearBuildPath = False` it should be okay to use that Builder with any directory (such is the case for the Publish Builder, which zips the contents of any directory and uploads them to an online repository). Conversely, take note of where `"clear_build_path": true` is set.

### Where Are These "Builders"?

All Builders are searched for in the local file system from where ebbs was called within the following folders:
```python
"./eons" #per the eons.Executor.defaultRepoDirectory
```

If the build you specified is not found within one of those directories, ebbs will try to download it from the remote repository with a name of `{builder}.build`. The downloaded build script will be saved to whatever directory you set in `--repo-store` (default "./eons/").

Unfortunately, python class names cannot have dashes ("-") in them. Instead, a series of underscores (`_`) is often used instead. While this deviates from the eons naming schema, it should still be intelligible for short names. You are, of course, welcome to use whatever naming scheme you would like instead!

### The Build Path

As mentioned, ebbs depends on the directory it is invoked from. The `rootPath` provided to each Builder will be this directory. The `buildPath` is specified relative to the `rootPath`. If you would like to use a single folder for all Builders, please set the `repo_store` environment variable with an absolute path.

For example, if you have a "git" and a "workspace" folder in your home directory and you want to use your custom Builder, "my_build" on all the projects in the git folder, instead of copying my_build to every project's workspace, you could simply `export repo_store="~/workspace"` and call ebbs from the appropriate build directory for each project.
Something like: `me@mine:~/git/my_cpp_project.exe/build$ ebbs -b my_build`. NOTE: if the build.json file `~/git/my_cpp_project.exe/build/build.json` exists, it will affect the behavior of `my_build` and potentially even effect other Builders. To ensure no side-effects are generated from project build configurations, you should create an empty folder to invoke your custom build process from (e.g `local/`).

Your home folder would then look something like:
```
home/
├─ git/
│  ├─ my_cpp_project.exe/
├─ workspace/
│  ├─ my_build.py
```

### Repository

Online repository settings can be specified with:
```
--repo-store (default = ./eons/)
--repo-url (default = https://api.infrastructure.tech/v1/package)
--repo-username
--repo-password
```

NOTE: you do not need to supply any repo credentials or other settings in order to download packages from the public repository.

For more info on the repo integration, see [the eons library](https://github.com/eons-dev/lib_eons#online-repository)

It is also worth noting that the online repository system is handled upstream (and downstream, for Publish) of ebbs.

By default, ebbs will use the [infrastructure.tech](https://infrastructure.tech) package repository. See the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv) for more info.

**IMPORTANT CAVEAT FOR ONLINE PACKAGES:** the package name must be suffixed with the "build" extension to be found by ebbs.  
For example, if you want to use `-b my_build` from the repository, ebbs will attempt to download "my_build.build". The package zip (my_build.build.zip) is then downloaded, extracted, registered, and instantiated.  
All packages are .zip files.

### Example Build Scripts:

* [Python](https://github.com/eons-dev/py.build)
* [C++](https://github.com/eons-dev/cpp.build)
* [Docker](https://github.com/eons-dev/docker.build)
* [Publish](https://github.com/eons-dev/publish.build) <- this one makes other Builders available online.
* [In Container](https://github.com/eons-dev/in_container.build) <- this one moves the remaining build process into a docker container.
* [Arbitrary](https://github.com/eons-dev/arbitrary.build) <- this one just runs commands.
* [Proxy](https://github.com/eons-dev/proxy.build) <- this one loads another json config file.
* [Test](https://github.com/eons-dev/test.build) <- this one runs commands and validates the outputs.

### Cascading Builds

As with any good build system, you aren't limited to just one step or even one file. With ebbs, you can specify "next" in your build.json (see below), which will execute a series of Builders after the initial.

Here's an example build.json that builds a C++ project then pushes it to Dockerhub (taken from the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv)):
```json
{
  "clear_build_path" : true,
  "next": [
	{
	  "build" : "in_container",
	  "config" : {
		"image" : "eons/dev-webserver.img",
		"copy_env" : [
		  "docker_username",
		  "docker_password"
		],
		"next" : [
		  {
			"build" : "cpp",
			"build_in" : "build",
			"copy" : [
			  {"../../inc/" : "inc/"},
			  {"../../src/" : "src/"}
			],
	        "config" : {
              "file_name" : "entrypoint",
              "cpp_version" : 17,
              "libs_shared": [
                "restbed",
                "cpr"
              ],
              "next" : [
                {
                  "build": "docker",
                  "path" : "infrastructure.srv",
                  "copy" : [
                    {"out/" : "src/"}
                  ],
                  "config" : {
                    "base_image" : "eons/webserver.img",
                    "image_name" : "eons/infrastructure.srv",
                    "image_os" : "debian",
                    "entrypoint" : "/usr/local/bin/entrypoint",
                    "also" : [
                      "EXPOSE 80"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
```
This script can be invoked with just `ebbs` (assuming the appropriate docker credentials are stored in your environment, docker is installed, etc.).

For other examples, check out the `build` folder of this repo and any other mentioned above!

## Design

### I Want One!

Before diving too deep into EBBS, please also give a quick look at the parent library: [eons](https://github.com/eons-dev/eons.lib).
The [UserFunctor Utilities](https://github.com/eons-dev/eons.lib#user-functor) will be of particular use in your Builders.

Ebbs builds packages or whatever with `ebbs.Builders`, which extend the self-registering `eons.UserFunctor`. This means you can write your own build scripts and publish them, distribute them with your code, or store them locally in the `repo_store` (see above). A major driving force behind ebbs is to encourage you to share your automation tools with colleagues, friends, and enemies! For example, you could create "my_build.py", containing something like:
```python
import logging
from ebbs import Builder

class my_build(Builder):
    def __init__(this, name="My Build"):
        super().__init__(name)
        
        # delete whatever dir was provided to this, so we can start fresh.
        this.clearBuildPath = True
        
        this.supportedProjectTypes = [] #all
        #or
        # this.supportedProjectTypes.append("lib")
        # this.supportedProjectTypes.append("exe")
        # this.supportedProjectTypes.append("test")
        
        #this.requiredKWArgs will cause an error to be thrown prior to execution (i.e. .*Build methods) iff they are not found in the system environment, build.json, nor command line.
        this.requiredKWArgs.append("my_required_arg")
        
        #this.my_optional_arg will be "some default value" unless the user overrides it from the command line or build.json file.
        this.optionalKWArgs["my_optional_arg"] = "some default value"
        
    #Check if the output of all your this.RunCommand() and whatever other calls did what you expected.
    #The "next" step will only be executed if this step succeeded.
    def DidBuildSucceed(this):
        return True; #yeah, why not?

    def PreBuild(this):
        logging.info(f"Got {this.my_required_arg} and {this.my_optional_arg}")
        
    #Required Builder method. See that class for details.
    def Build(this):
        #DO STUFF!
```
That file can then go in a "./ebbs/" or "./eons/" directory, perhaps within your project repository or on [infrastructure.tech](https://infrastructure.tech)!
ebbs can then be invoked with something like: `ebbs -b my_build --my-required-arg my-value`, which will run your Builder in the current path!

Also note the "--" preceding "--my-required-arg", which evaluates to "my_required_arg" (without the "--" and with "_" in place of "-") once in the Builder. This is done for convenience of both command line syntax and python code.

You could also do something like:
```shell
cat << EOF > ./build.json
{
  "my_required_arg" : "my-value",
  "my_optional_arg" : [
    "some",
    "other",
    "value",
    "that",
    "you",
    "don't",
    "want",
    "to",
    "type"
  ]
}
EOF

ebbs -b my_build
```
Here, the build.json file will be automatically read in, removing the need to specify the args for your build.

If you'd like to take this a step further, you can remove the need for `-b my_build` by specifying it under an empty builder in the build.json, like so:

```shell
cat << EOF > ./build.json
{
  "next": [
    {
      "build" : "my_build",
      "build_in" : "build",
      "copy" : [
        {"../src/" : "src/"},
        {"../inc/" : "inc/"},
        {"../test/" : "test/"}
      ],
      "config" : {
        "my_required_arg" : "my-value",
        "my_optional_arg" : [
          "some",
          "other",
          "value",
          "that",
          "you",
          "don't",
          "want",
          "to",
          "type"
        ]
      }
    }
  ]
}
EOF

ebbs #no args needed!
```

Regarding `this.clearBuildPath`, as mentioned above, it is important to not call ebbs on the wrong directory. If your Builder does not need a fresh build path, set `this.clearBuildPath = False`.
With that said, most compilation, packaging, etc. can be broken by stale data from past builds, so make sure to set `this.clearBuildPath = True` if you need to.

You may also have noticed the combination of camelCase and snake_case. This is used to specify builtInValues from user_provided_values. This convention may change with a future release (let us know what you think!).

For `supportedProjectTypes`, the `Builder` class will split the folder containing the buildPath (i.e. the `rootPath`) on underscores (`_`), storing the first value as `this.projectType` and the second as `this.projectName`. The `projectType` is checked against the used build's `supportedProjectTypes`. If no match is found, the build is aborted prior to executing the build. If you would like your Builder to work with all project types (and thus ignore that whole naming nonsense), set `this.supportedProjectTypes = []`, where none (i.e. `[]`, not actually `None`) means "all".


You'll also get the following paths variables populated by default:
```python
this.srcPath = f"{this.rootPath}/src"
this.incPath = f"{this.rootPath}/inc"
this.depPath = f"{this.rootPath}/dep"
this.libPath = f"{this.rootPath}/lib"
this.exePath = f"{this.rootPath}/exe"
this.testPath = f"{this.rootPath}/test"
```

When a `Builder` is executed, the following are called in order:  
(kwargs is the same for all)
```python
this.ValidateArgs() # <- not recommended to override.
this.BeforeFunction() # <- virtual (ok to override)
#Builder sets the above mentioned variables here
this.PreBuild() # <- virtual (ok to override)
#Supported project types are checked here
this.Build() # <- abstract method for you  (MUST override)
this.PostBuild() # <- virtual (ok to override)
if (this.DidBuildSucceed()):
    this.BuildNext()
this.AfterFunction() # <- virtual (ok to override)
```


%package help
Summary:	Development documents and examples for ebbs
Provides:	python3-ebbs-doc
%description help
# Eons Basic Build System

EBBS (or ebbs) is a framework for designing modular build pipelines for any language and system. Builders are python scripts that are downloaded and run on the fly with configuration provided by json config files, environment variables, and command line arguments!

Here, at eons, we have found building and distributing code to be too hard and far too disparate between languages. Thus, we designed ebbs to make packaging and distributing code consistent. No matter what language you're working with and no matter what you want to do with your code.

Want to compile C++ in a containerized environment then publish that code as an image back to Docker? How about publish your python code to PyPI or even just build a simple Wordpress plugin? No matter how intricate or big your project becomes, you'll be able to rely on ebbs to automate every step of your build process. It's just python. That's literally it.

With ebbs, there will be no more:
 * having to learn a new way to package code for every language.
 * having to change your code to fit your build system.
 * having to specify unnecessary configuration for every project.

Instead, you write your code the way you want and your ebbs build system will put the pieces together for you.
Ebbs has been written in adherence to the [eons naming conventions](https://eons.llc/convention/naming/) and [eons directory conventions](https://eons.llc/convention/uri-names/). However, we do try to make overriding these conventions as easy as possible so that you don't have to change your existing code to use our systems.

 For example, if you use "include" instead of the eons-preferred "inc", you can tell ebbs:
```json
"copy" : [
  {"../include" : "inc"}
]
```
In the same fashion, you can bypass the eons directory scheme ("my_project.exe", "my_project.lib", "my_project.img", etc.) by specifying `"name" : "my_project"` and `"type" : "exe"` or whatever you'd like.

If you find ebbs to be getting in the way or overly challenging, let us know! Seriously, building code should be easy and we're always happy to know how we can improve. Feel free to open issues or just email us at support@eons.llc.

## Installation
`pip install ebbs`

## Usage

Ebbs must be invoked from the directory you wish to build from.
For example, a well-designed project should allow you compile it locally by:
```shell
cd build
ebbs
```

Per (eons)[https://github.com/eons-dev/eons.lib], ebbs supports:
* `-v` or `--verbose` (count, i.e `-vv` = 2) or `--verbosity #`, where # is some number, or the `verbosity` environment or config value: will show more information and increase the logging level, e.g. print debug messages (3 for debug; 2 for info).
* `--config` or `-c` (string): the path to a json config file from which other values may be retrieved.
* `--no-repo` or the `no_repo` environment or config value (bool, i.e. 'True', 'true', etc.): whether or not to enable reaching out to online servers for code (see Dynamic Functionality, below).
* `--log-file` or the `log_file` environment or config value (string; supports formatting, e.g. '/var/log/eons/{this.name}.log'): optional value for logging to a file in addition to stderr.

As always, use `ebbs --help` for help ;)

### Configuration

Ebbs is intended to keep your build process separate from your code. With that said, it can be useful to specify some project-wide settings and build configurations.
Note that there isn't any real reason you can't move the build.json or even write an ebbs script to generate build.json and then call ebbs with it ;)

When running ebbs, the builder you select will pull its configuration values from the following external sources:
 1. the command line (e.g. in case you want to override anything)
 2. a "build.json" in the provided build folder (which can be specified via `--config`)
 3. a json file provided to `ebbs`.
 4. the system environment (e.g. for keeping passwords out of repo-files and commands)
Any existing member variables will override these external values.

You can manually specify the builder you'd like in one of 2 ways:
 1. the `-b` argument to ebbs.
 2. `"build" : "SOMETHING"` in the build.json

Lastly, you can specify a build folder (i.e. a folder to create within your project for all build output) with:
 1. `-i` on the cli; the default is "build" (e.g. "/path/to/my/project/build")
 2. `"build_in" : "BUILD_FOLDER"` in the build.json

You can also specify any number of other arguments in any of the command line, build.json, and system environments.
For example, `export pypi_username="__token__"` would make `this.Fetch('pypi_username)` in the "py" Builder return `__token__`, assuming you don't set `"pypi_username" : "something else"` in the build.json nor specify `--pypi-username "something else"` on the command line.

**IMPORTANT NOTE: Most ebbs Builders will DELETE the build folder you pass to them.**

This is done so that previous builds cannot create stale data which influence future builds. However, if you mess up and call, say, `ebbs -b cpp` from `./src` instead of from `./build`, you could lose your "src" folder. Please use this tool responsibly and read up on what each Builder does.
To make things easy, you can search for `clearBuildPath` in the python file and `clear_build_path` in the config files. If you see `this.clearBuildPath = False` it should be okay to use that Builder with any directory (such is the case for the Publish Builder, which zips the contents of any directory and uploads them to an online repository). Conversely, take note of where `"clear_build_path": true` is set.

### Where Are These "Builders"?

All Builders are searched for in the local file system from where ebbs was called within the following folders:
```python
"./eons" #per the eons.Executor.defaultRepoDirectory
```

If the build you specified is not found within one of those directories, ebbs will try to download it from the remote repository with a name of `{builder}.build`. The downloaded build script will be saved to whatever directory you set in `--repo-store` (default "./eons/").

Unfortunately, python class names cannot have dashes ("-") in them. Instead, a series of underscores (`_`) is often used instead. While this deviates from the eons naming schema, it should still be intelligible for short names. You are, of course, welcome to use whatever naming scheme you would like instead!

### The Build Path

As mentioned, ebbs depends on the directory it is invoked from. The `rootPath` provided to each Builder will be this directory. The `buildPath` is specified relative to the `rootPath`. If you would like to use a single folder for all Builders, please set the `repo_store` environment variable with an absolute path.

For example, if you have a "git" and a "workspace" folder in your home directory and you want to use your custom Builder, "my_build" on all the projects in the git folder, instead of copying my_build to every project's workspace, you could simply `export repo_store="~/workspace"` and call ebbs from the appropriate build directory for each project.
Something like: `me@mine:~/git/my_cpp_project.exe/build$ ebbs -b my_build`. NOTE: if the build.json file `~/git/my_cpp_project.exe/build/build.json` exists, it will affect the behavior of `my_build` and potentially even effect other Builders. To ensure no side-effects are generated from project build configurations, you should create an empty folder to invoke your custom build process from (e.g `local/`).

Your home folder would then look something like:
```
home/
├─ git/
│  ├─ my_cpp_project.exe/
├─ workspace/
│  ├─ my_build.py
```

### Repository

Online repository settings can be specified with:
```
--repo-store (default = ./eons/)
--repo-url (default = https://api.infrastructure.tech/v1/package)
--repo-username
--repo-password
```

NOTE: you do not need to supply any repo credentials or other settings in order to download packages from the public repository.

For more info on the repo integration, see [the eons library](https://github.com/eons-dev/lib_eons#online-repository)

It is also worth noting that the online repository system is handled upstream (and downstream, for Publish) of ebbs.

By default, ebbs will use the [infrastructure.tech](https://infrastructure.tech) package repository. See the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv) for more info.

**IMPORTANT CAVEAT FOR ONLINE PACKAGES:** the package name must be suffixed with the "build" extension to be found by ebbs.  
For example, if you want to use `-b my_build` from the repository, ebbs will attempt to download "my_build.build". The package zip (my_build.build.zip) is then downloaded, extracted, registered, and instantiated.  
All packages are .zip files.

### Example Build Scripts:

* [Python](https://github.com/eons-dev/py.build)
* [C++](https://github.com/eons-dev/cpp.build)
* [Docker](https://github.com/eons-dev/docker.build)
* [Publish](https://github.com/eons-dev/publish.build) <- this one makes other Builders available online.
* [In Container](https://github.com/eons-dev/in_container.build) <- this one moves the remaining build process into a docker container.
* [Arbitrary](https://github.com/eons-dev/arbitrary.build) <- this one just runs commands.
* [Proxy](https://github.com/eons-dev/proxy.build) <- this one loads another json config file.
* [Test](https://github.com/eons-dev/test.build) <- this one runs commands and validates the outputs.

### Cascading Builds

As with any good build system, you aren't limited to just one step or even one file. With ebbs, you can specify "next" in your build.json (see below), which will execute a series of Builders after the initial.

Here's an example build.json that builds a C++ project then pushes it to Dockerhub (taken from the [Infrastructure web server](https://github.com/infrastructure-tech/infrastructure.srv)):
```json
{
  "clear_build_path" : true,
  "next": [
	{
	  "build" : "in_container",
	  "config" : {
		"image" : "eons/dev-webserver.img",
		"copy_env" : [
		  "docker_username",
		  "docker_password"
		],
		"next" : [
		  {
			"build" : "cpp",
			"build_in" : "build",
			"copy" : [
			  {"../../inc/" : "inc/"},
			  {"../../src/" : "src/"}
			],
	        "config" : {
              "file_name" : "entrypoint",
              "cpp_version" : 17,
              "libs_shared": [
                "restbed",
                "cpr"
              ],
              "next" : [
                {
                  "build": "docker",
                  "path" : "infrastructure.srv",
                  "copy" : [
                    {"out/" : "src/"}
                  ],
                  "config" : {
                    "base_image" : "eons/webserver.img",
                    "image_name" : "eons/infrastructure.srv",
                    "image_os" : "debian",
                    "entrypoint" : "/usr/local/bin/entrypoint",
                    "also" : [
                      "EXPOSE 80"
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
```
This script can be invoked with just `ebbs` (assuming the appropriate docker credentials are stored in your environment, docker is installed, etc.).

For other examples, check out the `build` folder of this repo and any other mentioned above!

## Design

### I Want One!

Before diving too deep into EBBS, please also give a quick look at the parent library: [eons](https://github.com/eons-dev/eons.lib).
The [UserFunctor Utilities](https://github.com/eons-dev/eons.lib#user-functor) will be of particular use in your Builders.

Ebbs builds packages or whatever with `ebbs.Builders`, which extend the self-registering `eons.UserFunctor`. This means you can write your own build scripts and publish them, distribute them with your code, or store them locally in the `repo_store` (see above). A major driving force behind ebbs is to encourage you to share your automation tools with colleagues, friends, and enemies! For example, you could create "my_build.py", containing something like:
```python
import logging
from ebbs import Builder

class my_build(Builder):
    def __init__(this, name="My Build"):
        super().__init__(name)
        
        # delete whatever dir was provided to this, so we can start fresh.
        this.clearBuildPath = True
        
        this.supportedProjectTypes = [] #all
        #or
        # this.supportedProjectTypes.append("lib")
        # this.supportedProjectTypes.append("exe")
        # this.supportedProjectTypes.append("test")
        
        #this.requiredKWArgs will cause an error to be thrown prior to execution (i.e. .*Build methods) iff they are not found in the system environment, build.json, nor command line.
        this.requiredKWArgs.append("my_required_arg")
        
        #this.my_optional_arg will be "some default value" unless the user overrides it from the command line or build.json file.
        this.optionalKWArgs["my_optional_arg"] = "some default value"
        
    #Check if the output of all your this.RunCommand() and whatever other calls did what you expected.
    #The "next" step will only be executed if this step succeeded.
    def DidBuildSucceed(this):
        return True; #yeah, why not?

    def PreBuild(this):
        logging.info(f"Got {this.my_required_arg} and {this.my_optional_arg}")
        
    #Required Builder method. See that class for details.
    def Build(this):
        #DO STUFF!
```
That file can then go in a "./ebbs/" or "./eons/" directory, perhaps within your project repository or on [infrastructure.tech](https://infrastructure.tech)!
ebbs can then be invoked with something like: `ebbs -b my_build --my-required-arg my-value`, which will run your Builder in the current path!

Also note the "--" preceding "--my-required-arg", which evaluates to "my_required_arg" (without the "--" and with "_" in place of "-") once in the Builder. This is done for convenience of both command line syntax and python code.

You could also do something like:
```shell
cat << EOF > ./build.json
{
  "my_required_arg" : "my-value",
  "my_optional_arg" : [
    "some",
    "other",
    "value",
    "that",
    "you",
    "don't",
    "want",
    "to",
    "type"
  ]
}
EOF

ebbs -b my_build
```
Here, the build.json file will be automatically read in, removing the need to specify the args for your build.

If you'd like to take this a step further, you can remove the need for `-b my_build` by specifying it under an empty builder in the build.json, like so:

```shell
cat << EOF > ./build.json
{
  "next": [
    {
      "build" : "my_build",
      "build_in" : "build",
      "copy" : [
        {"../src/" : "src/"},
        {"../inc/" : "inc/"},
        {"../test/" : "test/"}
      ],
      "config" : {
        "my_required_arg" : "my-value",
        "my_optional_arg" : [
          "some",
          "other",
          "value",
          "that",
          "you",
          "don't",
          "want",
          "to",
          "type"
        ]
      }
    }
  ]
}
EOF

ebbs #no args needed!
```

Regarding `this.clearBuildPath`, as mentioned above, it is important to not call ebbs on the wrong directory. If your Builder does not need a fresh build path, set `this.clearBuildPath = False`.
With that said, most compilation, packaging, etc. can be broken by stale data from past builds, so make sure to set `this.clearBuildPath = True` if you need to.

You may also have noticed the combination of camelCase and snake_case. This is used to specify builtInValues from user_provided_values. This convention may change with a future release (let us know what you think!).

For `supportedProjectTypes`, the `Builder` class will split the folder containing the buildPath (i.e. the `rootPath`) on underscores (`_`), storing the first value as `this.projectType` and the second as `this.projectName`. The `projectType` is checked against the used build's `supportedProjectTypes`. If no match is found, the build is aborted prior to executing the build. If you would like your Builder to work with all project types (and thus ignore that whole naming nonsense), set `this.supportedProjectTypes = []`, where none (i.e. `[]`, not actually `None`) means "all".


You'll also get the following paths variables populated by default:
```python
this.srcPath = f"{this.rootPath}/src"
this.incPath = f"{this.rootPath}/inc"
this.depPath = f"{this.rootPath}/dep"
this.libPath = f"{this.rootPath}/lib"
this.exePath = f"{this.rootPath}/exe"
this.testPath = f"{this.rootPath}/test"
```

When a `Builder` is executed, the following are called in order:  
(kwargs is the same for all)
```python
this.ValidateArgs() # <- not recommended to override.
this.BeforeFunction() # <- virtual (ok to override)
#Builder sets the above mentioned variables here
this.PreBuild() # <- virtual (ok to override)
#Supported project types are checked here
this.Build() # <- abstract method for you  (MUST override)
this.PostBuild() # <- virtual (ok to override)
if (this.DidBuildSucceed()):
    this.BuildNext()
this.AfterFunction() # <- virtual (ok to override)
```


%prep
%autosetup -n ebbs-2.2.21

%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-ebbs -f filelist.lst
%dir %{python3_sitelib}/*

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

%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 2.2.21-1
- Package Spec generated