ScriptCollection 4.3.58__py3-none-any.whl → 4.3.60__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
39
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
40
40
  from .SCLog import SCLog, LogLevel
41
41
 
42
- version = "4.3.58"
42
+ version = "4.3.60"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -263,15 +263,16 @@ class TFCPS_CodeUnit_BuildCodeUnits:
263
263
  '~/.ScriptCollection/TFCPS', so it is outside of any repository and is not part of a product's sourcecode.
264
264
  Which script is used depends on where the build runs, because both cases need different preparation-steps:
265
265
  - build directly on the host ('scbuildcodeunits'): 'CustomPreCodeUnitBuildScript.py'
266
- - build inside the container ('scbuildcodeunitsc' or a build-pipeline): 'CustomPreCodeUnitBuildScriptInContainer.py'. It is
267
- searched in the folder into which 'scbuildcodeunitsc' mounts that single script and - if it is not there - in the
268
- configuration-folder, because a build-runner usually gets the whole configuration-folder mounted instead (see the article
269
- 'Build-runner-configuration'). The script which the host itself runs before it starts the container is
270
- 'CustomPreCodeUnitBuildScriptForContainer.py' and is therefore run there and not here."""
266
+ - build inside the container ('scbuildcodeunitsc' or a build-pipeline): 'CustomPreCodeUnitBuildScriptInContainer.py', located in
267
+ the folder returned by TFCPS_Tools_General.get_custom_scripts_folder_for_container(). It is searched in the folder into which
268
+ 'scbuildcodeunitsc' mounts that whole folder and - if it is not there - directly in the configuration-folder, because a
269
+ build-runner usually gets the whole configuration-folder mounted instead (see the article 'Build-runner-configuration'). The
270
+ script which the host itself runs before it starts the container is 'CustomPreCodeUnitBuildScriptForContainer.py' and is
271
+ therefore run there and not here."""
271
272
  if self.sc.is_runnning_in_container():
272
273
  script_file: str = os.path.join(self.tfcps_tools_general.get_folder_of_custom_scripts_in_container(), "CustomPreCodeUnitBuildScriptInContainer.py")
273
274
  if not os.path.isfile(script_file):
274
- script_file = self.tfcps_tools_general.get_custom_script_file("CustomPreCodeUnitBuildScriptInContainer.py")
275
+ script_file = os.path.join(self.tfcps_tools_general.get_custom_scripts_folder_for_container(), "CustomPreCodeUnitBuildScriptInContainer.py")
275
276
  else:
276
277
  script_file: str = self.tfcps_tools_general.get_custom_script_file("CustomPreCodeUnitBuildScript.py")
277
278
  self.tfcps_tools_general.run_custom_script_if_available(script_file, self.__get_build_arguments(self.repository))
@@ -322,12 +323,16 @@ class TFCPS_CodeUnit_BuildCodeUnits:
322
323
  #it runs before the environment-variables are resolved, so it can also create the files their values are read from.
323
324
  self.tfcps_tools_general.run_custom_script_if_available(self.tfcps_tools_general.get_custom_script_file("CustomPreCodeUnitBuildScriptForContainer.py"), self.__get_build_arguments(self.repository))
324
325
 
325
- #mount the optional user-specific script which prepares the container itself. it is mounted read-only because the container is not supposed to change the host-configuration.
326
- #the build inside the container runs it (see __run_custom_pre_codeunit_build_script); if the file does not exist on the host nothing is mounted and nothing is run.
326
+ #mount the optional user-specific scripts which prepare the container itself. the whole folder (not only the pre-codeunit-build-hook
327
+ #itself) is mounted, so the hook can start a sibling script placed next to it (for example to keep the hook independent of a
328
+ #package it only installs, while the actual preparation-logic which needs that package lives in the sibling script; see
329
+ #get_custom_scripts_folder_for_container). The mount is writable (not read-only) because the scripts in that folder also use it as
330
+ #their own download-cache-folder. The build inside the container runs the hook (see __run_custom_pre_codeunit_build_script); if the
331
+ #folder does not exist on the host nothing is mounted and nothing is run.
327
332
  mount_arguments: list[str] = []
328
- custom_script_for_inside_the_container: str = self.tfcps_tools_general.get_custom_script_file("CustomPreCodeUnitBuildScriptInContainer.py")
329
- if os.path.isfile(custom_script_for_inside_the_container):
330
- mount_arguments += ["-v", f"{custom_script_for_inside_the_container}:{self.tfcps_tools_general.get_folder_of_custom_scripts_in_container()}/CustomPreCodeUnitBuildScriptInContainer.py:ro"]
333
+ custom_scripts_folder_for_inside_the_container: str = self.tfcps_tools_general.get_custom_scripts_folder_for_container()
334
+ if os.path.isdir(custom_scripts_folder_for_inside_the_container):
335
+ mount_arguments += ["-v", f"{custom_scripts_folder_for_inside_the_container}:{self.tfcps_tools_general.get_folder_of_custom_scripts_in_container()}"]
331
336
 
332
337
  #pass the environment-variables which are declared as required in <repository>/.ScriptCollection/ProductInformation.xml into the container
333
338
  #so they do not have to be specified explicitly on every scbuildcodeunits-call. Their values are resolved from the user-specific
@@ -470,7 +470,10 @@ class TFCPS_Tools_General:
470
470
  get_environment_variables_configuration_file().
471
471
  The 'requiredenvironmentvariables'-element itself is required and must be declared even when the product does not need any
472
472
  environment-variable (it stays empty then), so that it is always visible which environment-variables a product depends on
473
- instead of that information being absent by accident."""
473
+ instead of that information being absent by accident.
474
+ The names declared for this machine (see get_additional_required_environment_variable_names_for_this_machine) are always
475
+ appended, because they are required by machine-local tooling instead of by the repository itself and must therefore not be
476
+ declared by (and are not specific to) any particular repository."""
474
477
  product_information_file = os.path.join(repository, ".ScriptCollection", "ProductInformation.xml")
475
478
  GeneralUtilities.assert_file_exists(product_information_file)
476
479
  root: etree._ElementTree = etree.parse(product_information_file)
@@ -485,6 +488,31 @@ class TFCPS_Tools_General:
485
488
  GeneralUtilities.assert_condition(GeneralUtilities.string_has_content(name), f"'{product_information_file}' contains a 'requiredenvironmentvariable'-element without a name. Every declared environment-variable must have a name.")
486
489
  GeneralUtilities.assert_condition(name not in result, f"'{product_information_file}' declares the environment-variable '{name}' more than once.")
487
490
  result.append(name)
491
+ for name in self.get_additional_required_environment_variable_names_for_this_machine():
492
+ if name not in result:
493
+ result.append(name)
494
+ return result
495
+
496
+ @GeneralUtilities.check_arguments
497
+ def get_additional_required_environment_variable_names_for_this_machine(self) -> list[str]:
498
+ """Returns the names of environment-variables which are additionally required for every codeunit-build which runs on this
499
+ machine, regardless of what a repository declares in its ProductInformation.xml. They are declared (name-only, one per line,
500
+ lines starting with '#' are treated as comments) in '<configuration-folder>/TFCPS/AdditionalRequiredEnvironmentVariables.txt'.
501
+ This file is deliberately kept outside of any repository: it exists so that tooling which is specific to one developer's machine
502
+ (for example a custom pre-codeunit-build-script, see run_custom_script_if_available) can declare the environment-variables it
503
+ needs without forcing every repository which happens to be built on that machine to declare them too - a repository must not
504
+ have to know about a specific developer's machine-local tooling.
505
+ The file is optional; if it does not exist nothing is additionally required."""
506
+ file = os.path.join(GeneralUtilities.get_scriptcollection_configuration_folder(), "TFCPS", "AdditionalRequiredEnvironmentVariables.txt")
507
+ result: list[str] = []
508
+ if not os.path.isfile(file):
509
+ return result
510
+ for line in GeneralUtilities.read_lines_from_file(file):
511
+ name = line.strip()
512
+ if not GeneralUtilities.string_has_content(name) or name.startswith("#"):
513
+ continue
514
+ if name not in result:
515
+ result.append(name)
488
516
  return result
489
517
 
490
518
  @GeneralUtilities.check_arguments
@@ -616,6 +644,20 @@ class TFCPS_Tools_General:
616
644
  repository on purpose: they contain machine-specific preparation-steps which must not be part of a product's sourcecode."""
617
645
  return os.path.join(GeneralUtilities.get_scriptcollection_configuration_folder(), "TFCPS", filename)
618
646
 
647
+ @GeneralUtilities.check_arguments
648
+ def get_custom_scripts_folder_for_container(self) -> str:
649
+ """Returns the folder (on the host) whose content is mounted as a whole into a locally started build-container by
650
+ build_codeunits_in_container, so it is the counterpart of get_folder_of_custom_scripts_in_container on the host-side. The mount is
651
+ writable (not read-only) because the scripts in that folder may also use it as their own download-cache-folder. It is a dedicated
652
+ subfolder of the configuration-folder - not the configuration-folder itself and not the same folder as get_custom_script_file uses
653
+ - so that mounting it into a container never exposes anything else from the configuration-folder (in particular not
654
+ EnvironmentVariables.csv or Secrets, which contain credentials).
655
+ Mounting the whole folder (instead of only the pre-codeunit-build-hook itself, "CustomPreCodeUnitBuildScriptInContainer.py") means
656
+ that hook can start a sibling script placed next to it in this same folder (see run_custom_script_if_available), which is what
657
+ lets the hook itself stay independent of a package it only installs, while the actual preparation-logic (which needs that package)
658
+ lives in the sibling script."""
659
+ return os.path.join(GeneralUtilities.get_scriptcollection_configuration_folder(), "TFCPS", "CustomScriptsForContainer")
660
+
619
661
  @GeneralUtilities.check_arguments
620
662
  def get_folder_of_custom_scripts_in_container(self) -> str:
621
663
  """Returns the folder inside the build-container into which the custom scripts of the host are mounted. It is an own folder
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.58
3
+ Version: 4.3.60
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
12
- ScriptCollection/ScriptCollectionCore.py,sha256=fJO9xg28OiiERt9mBD87SAb1IeMMrHYenOlYty2L_NE,247435
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=kqKwoy86fDSc6YmU1pFTq7CPfUuTRTBgBJN7ldgjVI0,247435
13
13
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
14
14
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
@@ -38,7 +38,7 @@ ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-
38
38
  ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW1NOCMiLMzOy48OqlJX-KY,1744
39
39
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=N-Wvxzwv_R8EVybjQjE7wXX-VpFLa_62LinWa57C_Wo,35345
40
40
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Ll5EOkpVpPiFrM2mLeQXolaF7075IwgtnHXvfdpkH4k,9904
41
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=CY4qvckKYPkyYmuTiplDX0jCzsFWqTTXy6cq6yicKjk,44171
41
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=TdyhK4KVMliYRs_kSCaKUfX6iOqYlj0uaiYbdwR0G5E,44683
42
42
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
43
43
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
44
44
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=zp7n0Li7GTi4tERDMgDcJ-o3m6131m31zvkat0lALEc,7781
@@ -46,7 +46,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=jQ0B3yq45we-8a0KuNFMfXCk9Mf
46
46
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
47
47
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=JYiDqDsfVJQWS9xWMi_UzfXnXsJRnPRxAzFr82bUEvI,2370
48
48
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=Z8Gw-j5I7VPafHEsVeQJ2gTTKVLAnnhwZhY8IVTi2Qk,11867
49
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=lHTCO9gd-GsN95i4Wytb6KBYb6EAsAHhp106Tc2XFCM,146799
49
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=_HwruhDuBfiaBGq0RLvHygH8leRE7jMwj2V788LYFh4,150354
50
50
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=iW1_5oE4EEThGa3QC_n8fuJFMQ5lkX_BlZ0jtmtC7sg,19474
52
52
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -67,8 +67,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
67
67
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
68
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
69
69
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
- scriptcollection-4.3.58.dist-info/METADATA,sha256=AR9f5bz8qgKOJpEuqiYPFRX5ITmM2WTk_LOZFL98I6c,7648
71
- scriptcollection-4.3.58.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
72
- scriptcollection-4.3.58.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
73
- scriptcollection-4.3.58.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
74
- scriptcollection-4.3.58.dist-info/RECORD,,
70
+ scriptcollection-4.3.60.dist-info/METADATA,sha256=qTuiVep93JcmjKYmIMfK1P0ado6xTK28zzWiDzGub6A,7648
71
+ scriptcollection-4.3.60.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
72
+ scriptcollection-4.3.60.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
73
+ scriptcollection-4.3.60.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
74
+ scriptcollection-4.3.60.dist-info/RECORD,,